Algebraic Effects and Handlers

Andrej Bauer

Basics

Take the operation symbol for plusplus:

plus:1×Z2Zplus: 1 \times \Z^2 \rightarrow \Z

3 + (4 + 5)

plus(b:2 if b = 0 then 3
         else plus(c:2 if c = 0 then 4
                       else 5))

Op ⁣:AnAOp \colon A^n \rightarrow A

where nn is the arity, or number of distinct effects


Op ⁣:B×AnAOp \colon B \times A^n \rightarrow A

where BB is the parameter type, a monad


Op ⁣:B×ACAOp \colon B \times A^C \rightarrow A

where CC is an unbounded type; a delimited continuation