Ability patterns (or Request
patterns)
An ability pattern only appears in an ability handler and has one of two forms (see Abilities and ability handlers for details):
{C p1 p2 ā¦ pn -> k}
whereC
is the name of an ability constructor in scope, andp1
throughpn
are patterns such thatn
is the arity ofC
. Note thatn
may be zero. This pattern matches if the scrutinee reduces to a fully applied invocation of the ability constructorC
and the patternsp1
throughpn
match the arguments to the constructor. The scrutinee must be of typeRequest A T
for some ability{A}
and typeT
. The variablek
will be bound to the continuation of the program. If the scrutinee has typeRequest A T
andC
has typeX ->{A} Y
, thenk
has typeY -> {A} T
.{p}
wherep
is a pattern. This matches the case where the computation is pure (the value of typeRequest A T
calls none of the constructors of the ability{A}
). A pattern match on aRequest
is not complete unless this case is handled.
See the section on abilities and ability handlers for examples of ability patterns.