Ability patterns (orRequest
patterns)
Anability patternonly appears in an ability handler and has one of two forms (seeAbilities and ability handlersfor 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 ispure(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 onabilities and ability handlersfor examples of ability patterns.