Continuation Monad #
@cite{barker-shan-2014} @cite{charlow-2021}
General-purpose continuation monad, following @cite{barker-shan-2014}.
The type Cont R A := (A → R) → R underlies lifted question types
(Lifted.lean), higher-order dynamic GQs, and
scope-taking expressions generally.
Key definitions #
The continuation monad: (A → R) → R.
An expression of type Cont R A takes a continuation A → R and
produces a result of type R.
Equations
- Semantics.Composition.Continuation.Cont R A = ((A → R) → R)
Instances For
def
Semantics.Composition.Continuation.Cont.map
{R : Type u}
{A : Type v}
{B : Type w}
(f : A → B)
(m : Cont R A)
:
Cont R B
Functorial map: apply a function under the continuation.
map f m = λκ. m(λa. κ(f(a)))
Equations
- Semantics.Composition.Continuation.Cont.map f m κ = m fun (a : A) => κ (f a)
Instances For
@[reducible, inline]
abbrev
Semantics.Composition.Continuation.Tower
(C : Type u)
(B : Type v)
(A : Type w)
:
Type (max (max u v) w)
Tower type abbreviation: (A → B) → C.
In Barker & Shan's notation, this is the flat reading of
C | B
─────
A
Equations
- Semantics.Composition.Continuation.Tower C B A = ((A → B) → C)
Instances For
Lower of pure is identity.