Documentation

Lake.Util.EStateT

inductive Lake.EResult (ε : Type u) (σ : Type v) (α : Type w) :
Type (max u v w)

EResult ε σ α is equivalent to Except ε α × σ, but using a single combined inductive yields a more efficient data representation.

  • ok {ε : Type u} {σ : Type v} {α : Type w} : ασEResult ε σ α

    A success value of type α, and a new state σ.

  • error {ε : Type u} {σ : Type v} {α : Type w} : εσEResult ε σ α

    A failure value of type ε, and a new state σ.

Instances For
instance Lake.instInhabitedEResult {α : Type u_1} {σ : Type u_2} {ε : Type u_3} [Inhabited α] [Inhabited σ] :
Inhabited (EResult ε σ α)
Equations
instance Lake.instInhabitedEResult_1 {ε : Type u_1} {σ : Type u_2} {α : Type u_3} [Inhabited ε] [Inhabited σ] :
Inhabited (EResult ε σ α)
Equations
@[inline]
def Lake.EResult.state {ε : Type u_1} {σ : Type u_2} {α : Type u_3} :
EResult ε σ ασ

Extract the state σ from a EResult ε σ α.

Equations
@[inline]
def Lake.EResult.modifyState {σ : Type u_1} {σ' : Type u_2} {ε : Type u_3} {α : Type u_4} (f : σσ') :
EResult ε σ αEResult ε σ' α
Equations
@[inline]
def Lake.EResult.setState {σ' : Type u_1} {ε : Type u_2} {σ : Type u_3} {α : Type u_4} (s : σ') (r : EResult ε σ α) :
EResult ε σ' α
Equations
@[inline]
def Lake.EResult.toProd {ε : Type u_1} {σ : Type u_2} {α : Type u_3} :
EResult ε σ αExcept ε α × σ

Convert a EResult ε σ α into Except ε α × σ.

Equations
@[inline]
def Lake.EResult.toProd? {ε : Type u_1} {σ : Type u_2} {α : Type u_3} :
EResult ε σ αOption α × σ

Convert an EResult ε σ α into Option α × σ, discarding the exception contents.

Equations
@[inline]
def Lake.EResult.result? {ε : Type u_1} {σ : Type u_2} {α : Type u_3} :
EResult ε σ αOption α

Extract the result α from a EResult ε σ α.

Equations
@[inline]
def Lake.EResult.error? {ε : Type u_1} {σ : Type u_2} {α : Type u_3} :
EResult ε σ αOption ε

Extract the error ε from a EResult ε σ α.

Equations
@[inline]
def Lake.EResult.toExcept {ε : Type u_1} {σ : Type u_2} {α : Type u_3} :
EResult ε σ αExcept ε α

Convert an EResult ε σ α into Except ε α, discarding its state.

Equations
@[inline]
def Lake.EResult.map {α : Type u_1} {β : Type u_2} {ε : Type u_3} {σ : Type u_4} (f : αβ) :
EResult ε σ αEResult ε σ β
Equations
instance Lake.instFunctorEResult {ε : Type u_1} {σ : Type u_2} :
Equations
def Lake.EStateT (ε : Type u) (σ : Type v) (m : Type (max u v w) → Type x) (α : Type w) :
Type (max v x)

EStateT ε σ m is a combined error and state monad transformer, equivalent to ExceptT ε (StateT σ m) but more efficient.

Equations
Instances For
instance Lake.EStateT.instInhabitedOfPure {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Inhabited ε] [Pure m] :
Inhabited (EStateT ε σ m α)
Equations
@[inline]
def Lake.EStateT.run {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max u v w) → Type u_1} (init : σ) (self : EStateT ε σ m α) :
m (EResult ε σ α)

Execute an EStateT on initial state init to get an EResult result.

Equations
@[inline]
def Lake.EStateT.run' {ε : Type u} {α : Type w} {m : Type (max u w) → Type u_1} {σ : Type (max u w)} [Functor m] (init : σ) (x : EStateT ε σ m α) :
m (Except ε α)

Execute an EStateT on initial state init to get an Except result, discarding the final state.

Equations
@[inline]
def Lake.EStateT.toStateT {m : Type u → Type u_1} {ε σ α : Type u} [Functor m] (x : EStateT ε σ m α) :
StateT σ m (Except ε α)

Convert an EStateT to a StateT, returning an Except result.

Equations
@[inline]
def Lake.EStateT.toStateT? {m : Type u → Type u_1} {ε σ α : Type u} [Functor m] (x : EStateT ε σ m α) :
StateT σ m (Option α)

Convert an EStateT to a StateT, returning an Option result.

Equations
@[inline]
def Lake.EStateT.run? {σ : Type v} {α : Type w} {m : Type (max v w) → Type u_1} {ε : Type (max v w)} [Functor m] (init : σ) (x : EStateT ε σ m α) :
m (Option α × σ)

Execute an EStateT on initial state init to get an Option result, discarding the exception contents.

Equations
@[inline]
def Lake.EStateT.run?' {m : Type u → Type u_1} {ε σ α : Type u} [Functor m] (init : σ) (x : EStateT ε σ m α) :
m (Option α)

Execute an EStateT on initial state init to get an Option result, discarding the final state.

Equations
@[inline]
def Lake.EStateT.catchExceptions {m : Type u → Type u_1} {ε σ α : Type u} [Monad m] (x : EStateT ε σ m α) (h : εStateT σ m α) :
StateT σ m α
Equations
@[inline]
def Lake.EStateT.lift {m : Type u → Type u_1} {ε σ α : Type u} [Monad m] (x : m α) :
EStateT ε σ m α

Lift the m monad into the EStateT ε σ m monad transformer.

Equations
instance Lake.EStateT.instMonadLiftOfMonad {m : Type u → Type u_1} {ε σ : Type u} [Monad m] :
MonadLift m (EStateT ε σ m)
Equations
@[inline]
def Lake.EStateT.pure {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Pure m] (a : α) :
EStateT ε σ m α

The pure operation of the EStateT monad transformer.

Equations
instance Lake.EStateT.instPure {ε : Type u} {σ : Type v} {m : Type (max (max u v) u_1) → Type u_2} [Pure m] :
Pure (EStateT ε σ m)
Equations
@[inline]
def Lake.EStateT.map {ε : Type u} {σ : Type v} {α β : Type w} {m : Type (max (max u v) w) → Type u_1} [Functor m] (f : αβ) (x : EStateT ε σ m α) :
EStateT ε σ m β

The map operation of the EStateT monad transformer.

Equations
  • One or more equations did not get rendered due to their size.
instance Lake.EStateT.instFunctor {ε : Type u} {σ : Type v} {m : Type (max (max u v) u_1) → Type u_2} [Functor m] :
Functor (EStateT ε σ m)
Equations
@[inline]
def Lake.EStateT.bind {ε : Type u} {σ : Type v} {α β : Type w} {m : Type (max (max u v) w) → Type u_1} [Monad m] (x : EStateT ε σ m α) (f : αEStateT ε σ m β) :
EStateT ε σ m β

The bind operation of the EStateT monad transformer.

Equations
@[inline]
def Lake.EStateT.seqRight {ε : Type u} {σ : Type v} {α β : Type w} {m : Type (max (max u v) w) → Type u_1} [Monad m] (x : EStateT ε σ m α) (y : UnitEStateT ε σ m β) :
EStateT ε σ m β

The seqRight operation of the EStateT monad transformer.

Equations
@[always_inline]
instance Lake.EStateT.instMonad {ε : Type u} {σ : Type v} {m : Type (max (max u v) u_1) → Type u_2} [Monad m] :
Monad (EStateT ε σ m)
Equations
@[inline]
def Lake.EStateT.set {ε : Type u} {σ : Type v} {m : Type (max (max u v) w) → Type u_1} [Pure m] (s : σ) :
EStateT ε σ m PUnit

The set operation of the EStateT monad.

Equations
@[inline]
def Lake.EStateT.get {ε : Type u} {σ : Type v} {m : Type (max u v) → Type u_1} [Pure m] :
EStateT ε σ m σ

The get operation of the EStateT monad.

Equations
@[inline]
def Lake.EStateT.modifyGet {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Pure m] (f : σα × σ) :
EStateT ε σ m α

The modifyGet operation of the EStateT monad transformer.

Equations
instance Lake.EStateT.instMonadStateOfOfPure {ε : Type u} {σ : Type v} {m : Type (max u v) → Type u_1} [Pure m] :
MonadStateOf σ (EStateT ε σ m)
Equations
@[inline]
def Lake.EStateT.throw {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Pure m] (e : ε) :
EStateT ε σ m α

The throw operation of the EStateT monad transformer.

Equations
@[inline]
def Lake.EStateT.tryCatch {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Monad m] (x : EStateT ε σ m α) (handle : εEStateT ε σ m α) :
EStateT ε σ m α
Equations
instance Lake.EStateT.instMonadExceptOfOfMonad {ε : Type u} {σ : Type v} {m : Type (max (max u v) u_1) → Type u_2} [Monad m] :
MonadExceptOf ε (EStateT ε σ m)
Equations
@[inline]
def Lake.EStateT.orElse {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Monad m] (x₁ : EStateT ε σ m α) (x₂ : UnitEStateT ε σ m α) :
EStateT ε σ m α
Equations
instance Lake.EStateT.instOrElseOfMonad {ε : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Monad m] :
OrElse (EStateT ε σ m α)
Equations
@[inline]
def Lake.EStateT.adaptExcept {ε ε' : Type u} {σ : Type v} {α : Type w} {m : Type (max (max u v) w) → Type u_1} [Functor m] (f : εε') (x : EStateT ε σ m α) :
EStateT ε' σ m α

Map the exception type of a EStateT ε σ m α by a function f : ε → ε'.

Equations
  • One or more equations did not get rendered due to their size.
@[always_inline]
instance Lake.EStateT.instMonadFinallyOfMonad {ε : Type u} {σ : Type v} {m : Type (max (max u v) u_1) → Type u_2} [Monad m] :
Equations
  • One or more equations did not get rendered due to their size.