The Exception monad transformer using CPS style.
@[instance_reducible]
Adds exceptions of type ε to a monad m.
Instead of using Except ε to model exceptions, this implementation uses continuation passing
style. This has different performance characteristics from ExceptT ε.
Equations
- ExceptCpsT ε m α = ((β : Type ?u.2) → (α → m β) → (ε → m β) → m β)
Instances For
@[inline]
def ExceptCpsT.run {m : Type u → Type u_1} {ε α : Type u} [Monad m] (x : ExceptCpsT ε m α) :
m (Except ε α)
Use a monadic action that may throw an exception as an action that may return an exception's value.
Equations
Instances For
@[inline]
def ExceptCpsT.runK {m : Type u → Type u_1} {β ε α : Type u} (x : ExceptCpsT ε m α) (ok : α → m β) (error : ε → m β) :
m β
Use a monadic action that may throw an exception by providing explicit success and failure continuations.
Instances For
@[instance_reducible, always_inline]
Equations
- One or more equations did not get rendered due to their size.
instance ExceptCpsT.instLawfulMonad {σ : Type u_1} {m : Type u_1 → Type u_2} :
LawfulMonad (ExceptCpsT σ m)
@[instance_reducible]
instance ExceptCpsT.instMonadExceptOf {ε : Type u_1} {m : Type u_1 → Type u_2} :
MonadExceptOf ε (ExceptCpsT ε m)
Equations
- One or more equations did not get rendered due to their size.
@[inline]
def ExceptCpsT.lift {m : Type u_1 → Type u_2} {α ε : Type u_1} [Monad m] (x : m α) :
ExceptCpsT ε m α
Run an action from the transformed monad in the exception monad.
Equations
- ExceptCpsT.lift x x✝¹ k x✝ = x >>= k
Instances For
@[instance_reducible]
instance ExceptCpsT.instMonadLiftOfMonad {m : Type u_1 → Type u_2} {σ : Type u_1} [Monad m] :
MonadLift m (ExceptCpsT σ m)
Equations
- ExceptCpsT.instMonadLiftOfMonad = { monadLift := fun {α : Type ?u.2} => ExceptCpsT.lift }
@[instance_reducible]
instance ExceptCpsT.instInhabited {ε : Type u_1} {m : Type u_1 → Type u_2} {α : Type u_1} [Inhabited ε] :
Inhabited (ExceptCpsT ε m α)
@[instance_reducible]
instance ExceptCpsT.instMonadAttach {ε : Type u_1} {m : Type u_1 → Type u_2} :
MonadAttach (ExceptCpsT ε m)
For continuation monads, it is not possible to provide a computable MonadAttach instance that
actually adds information about the return value. Therefore, this instance always attaches a proof
of True.
@[simp]
theorem ExceptCpsT.runCatch_lift {m : Type u → Type u_1} {α : Type u} [Monad m] [LawfulMonad m] (x : m α) :