Effect

An effect represents the signature of a side effect.

An expression can delegate to the caller the handling of a side effect, doing so will interrupt the function in order to call the handler, and resume the execution with the value returned by the handler.

The effect's signature MUST be used for type-checking at the handler's boundaries, meaning:

Syntax

effect_definition
effect [ signature ]
Show source
effect_definition
  = "effect" "[" signature "]"
signature
( type_expression , , ) -> type_expression
Show source
signature
  = "(" (type_expression ("," type_expression)* ","?)? ")" "->" type_expression

Example

let log: effect[(string) -> @ok];

let read_line: effect[() -> string];

let sort_compare<t>: effect[(t, t) -> bool];