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 = { default := Lake.EResult.ok default default }
Equations
- Lake.instInhabitedEResult_1 = { default := Lake.EResult.error default default }
Extract the state σ
from a EResult ε σ α
.
Equations
- x.state = match x with | Lake.EResult.ok a s => s | Lake.EResult.error a s => s
Instances For
Equations
- Lake.EResult.modifyState f x = match x with | Lake.EResult.ok a s => Lake.EResult.ok a (f s) | Lake.EResult.error e s => Lake.EResult.error e (f s)
Instances For
Equations
- Lake.EResult.setState s r = Lake.EResult.modifyState (fun (x : σ) => s) r
Instances For
Convert a EResult ε σ α
into Except ε α × σ
.
Equations
- x.toProd = match x with | Lake.EResult.ok a s => (Except.ok a, s) | Lake.EResult.error e s => (Except.error e, s)
Instances For
Convert an EResult ε σ α
into Option α × σ
, discarding the exception contents.
Equations
- x.toProd? = match x with | Lake.EResult.ok a s => (some a, s) | Lake.EResult.error a s => (none, s)
Instances For
Extract the result α
from a EResult ε σ α
.
Equations
- x.result? = match x with | Lake.EResult.ok a a_1 => some a | x => none
Instances For
Extract the error ε
from a EResult ε σ α
.
Equations
- x.error? = match x with | Lake.EResult.error e a => some e | x => none
Instances For
Convert an EResult ε σ α
into Except ε α
, discarding its state.
Equations
- x.toExcept = match x with | Lake.EResult.ok a a_1 => Except.ok a | Lake.EResult.error e a => Except.error e
Instances For
Equations
- Lake.EResult.map f x = match x with | Lake.EResult.ok a s => Lake.EResult.ok (f a) s | Lake.EResult.error e s => Lake.EResult.error e s
Instances For
Equations
- Lake.instFunctorEResult = { map := fun {α β : Type u_3} => Lake.EResult.map, mapConst := fun {α β : Type u_3} => 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
Equations
- Lake.EStateT.instInhabitedOfPure = { default := fun (s : σ) => pure (Lake.EResult.error default s) }
Execute an EStateT
on initial state init
to get an EResult
result.
Equations
- Lake.EStateT.run init self = self init
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 exception contents.
Equations
- Lake.EStateT.run? init x = Lake.EResult.toProd? <$> 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
Equations
- x.catchExceptions h s = do let __do_lift ← x s match __do_lift with | Lake.EResult.ok a s => pure (a, s) | Lake.EResult.error e s => h e s
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_1} => Lake.EStateT.map, mapConst := fun {α β : Type u_1} => Lake.EStateT.map ∘ Function.const β }
The bind
operation of the EStateT
monad transformer.
Equations
- x.bind f s = do let __do_lift ← x s match __do_lift with | Lake.EResult.ok a s => f a s | Lake.EResult.error e s => pure (Lake.EResult.error e s)
Instances For
The seqRight
operation of the EStateT
monad transformer.
Equations
- x.seqRight y s = do let __do_lift ← x s match __do_lift with | Lake.EResult.ok a s => y () s | Lake.EResult.error e s => pure (Lake.EResult.error e s)
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
The modifyGet
operation of the EStateT
monad transformer.
Equations
- Lake.EStateT.modifyGet f s = match f s with | (a, s) => pure (Lake.EResult.ok a s)
Instances For
The throw
operation of the EStateT
monad transformer.
Equations
- Lake.EStateT.throw e s = pure (Lake.EResult.error e 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
Equations
- x₁.orElse x₂ s = do let __do_lift ← x₁ s match __do_lift with | Lake.EResult.error a s => x₂ () s | ok => pure ok
Instances For
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.
Instances For
Equations
- One or more equations did not get rendered due to their size.