EResult ε σ α is equivalent to Except ε α × σ, but using a single
combined inductive yields a more efficient data representation.
- ok: {ε : Type u} → {σ : Type v} → {α : Type w} → α → σ → Lake.EResult ε σ α
A success value of type
α, and a new stateσ. - error: {ε : Type u} → {σ : Type v} → {α : Type w} → ε → σ → Lake.EResult ε σ α
A failure value of type
ε, and a new stateσ.
Instances For
Equations
- Lake.instInhabitedEResult_1 = { default := Lake.EResult.error default default }
Extract the state σ from a EResult ε σ α.
Equations
- (Lake.EResult.ok a s).state = s
- (Lake.EResult.error a s).state = s
Instances For
Instances For
Equations
- Lake.EResult.setState s r = Lake.EResult.modifyState (fun (x : σ) => s) r
Instances For
Convert a EResult ε σ α into Except ε α × σ.
Instances For
Convert an EResult ε σ α into Option α × σ, discarding the exception contents.
Instances For
Extract the result α from a EResult ε σ α.
Instances For
Extract the error ε from a EResult ε σ α.
Equations
- (Lake.EResult.error e a).error? = some e
- x.error? = none
Instances For
Convert an EResult ε σ α into Except ε α, discarding its state.
Equations
- (Lake.EResult.ok a s).toExcept = Except.ok a
- (Lake.EResult.error a s).toExcept = Except.error a
Instances For
Instances For
Equations
- Lake.instFunctorEResult = { map := fun {α β : Type ?u.24} => Lake.EResult.map, mapConst := fun {α β : Type ?u.24} => Lake.EResult.map ∘ Function.const β }
EStateT ε σ m is a combined error and state monad transformer,
equivalent to ExceptT ε (StateT σ m) but more efficient.
Equations
- Lake.EStateT ε σ m α = (σ → m (Lake.EResult ε σ α))
Instances For
Execute an EStateT on initial state init to get an EResult result.
Instances For
Execute an EStateT on initial state init
to get an Except result, discarding the final state.
Equations
- Lake.EStateT.run' init x = Lake.EResult.toExcept <$> x init
Instances For
Execute an EStateT on initial state init to get an Option result,
discarding the final state.
Equations
- Lake.EStateT.run?' init x = Lake.EResult.result? <$> x init
Instances For
Instances For
Lift the m monad into the EStateT ε σ m monad transformer.
Equations
- Lake.EStateT.lift x s = do let a ← x pure (Lake.EResult.ok a s)
Instances For
The pure operation of the EStateT monad transformer.
Equations
- Lake.EStateT.pure a s = pure (Lake.EResult.ok a s)
Instances For
The map operation of the EStateT monad transformer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lake.EStateT.instFunctor = { map := fun {α β : Type ?u.37} => Lake.EStateT.map, mapConst := fun {α β : Type ?u.37} => Lake.EStateT.map ∘ Function.const β }
The bind operation of the EStateT monad transformer.
Instances For
The seqRight operation of the EStateT monad transformer.
Instances For
Equations
- Lake.EStateT.instMonad = Monad.mk
The set operation of the EStateT monad.
Equations
- Lake.EStateT.set s x = pure (Lake.EResult.ok PUnit.unit s)
Instances For
The get operation of the EStateT monad.
Equations
- Lake.EStateT.get s = pure (Lake.EResult.ok s s)
Instances For
Equations
- x.tryCatch handle s = do let __do_lift ← x s match __do_lift with | Lake.EResult.error e s => handle e s | ok => pure ok
Instances For
Instances For
Map the exception type of a EStateT ε σ m α by a function f : ε → ε'.