# Signature:
# - Take 1 positional arg that is a Pair object that unpacks as:
# - its key is a Str object; make it available in $desc variable
# - its value is another Pair object; unpack it as:
# - its key must be a UInt that's thruthy (so > 0), save it in var $plan
# - its value must be a Callable object with signature that takes a
# single Int positional argument; save that callable into variable &g
#
# Attempting to call this sub with any other type of argument is a typecheck
# error, which can at times be checked even at compile-time.
sub group(
Pair (
Str :key($desc),
Pair :value((
UInt :key($plan) where .so,
:value( &g:(Int) ))))
) {
dd [ $desc, $plan, g $plan ]
}
group 'foo' => 3 => -> Int $p { say "hi $p"; 42 }
# OUTPUT:
# hi 3
# ["foo", 3, 42]