⛅ Coming soon: create Unison Cloud clusters in minutes on your own infrastructure. Learn more

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):

  1. {C p1 p2 … pn -> k} where C is the name of an ability constructor in scope, and p1 through pn are patterns such that n is the arity of C. Note that n may be zero. This pattern matches if the scrutinee reduces to a fully applied invocation of the ability constructor C and the patterns p1 through pn match the arguments to the constructor. The scrutinee must be of type Request A T for some ability {A} and type T. The variable k will be bound to the continuation of the program. If the scrutinee has type Request A T and C has type X ->{A} Y, then k has type Y -> {A} T.
  2. {p} where p is a pattern. This matches the case where the computation is pure (the value of type Request A T calls none of the constructors of the ability {A}). A pattern match on a Request is not complete unless this case is handled.

See the section on abilities and ability handlers for examples of ability patterns.