@[protected]
Equations
- except.return a = except.ok a
@[protected]
Equations
- except.map f (except.ok v) = except.ok (f v)
- except.map f (except.error err) = except.error err
@[protected]
Equations
- except.map_error f (except.ok v) = except.ok v
- except.map_error f (except.error err) = except.error (f err)
@[protected]
Equations
- ma.bind f = except.bind._match_1 f ma
- except.bind._match_1 f (except.ok v) = f v
- except.bind._match_1 f (except.error err) = except.error err
@[protected]
Equations
- (except.ok a).to_option = option.some a
- (except.error _x).to_option = option.none
@[protected, instance]
Equations
- run : m (except ε α)
Instances for except_t
@[protected]
def
except_t.return
{ε : Type u}
{m : Type u → Type v}
[monad m]
{α : Type u}
(a : α) :
except_t ε m α
Equations
- except_t.return a = ⟨has_pure.pure (except.ok a)⟩
@[protected]
def
except_t.bind_cont
{ε : Type u}
{m : Type u → Type v}
[monad m]
{α β : Type u}
(f : α → except_t ε m β) :
Equations
- except_t.bind_cont f (except.ok a) = (f a).run
- except_t.bind_cont f (except.error e) = has_pure.pure (except.error e)
@[protected, instance]
def
except_t.has_monad_lift
{ε : Type u}
{m : Type u → Type v}
[monad m] :
has_monad_lift m (except_t ε m)
Equations
- except_t.has_monad_lift = {monad_lift := except_t.lift _inst_1}
@[protected, instance]
def
except_t.monad_functor
{ε : Type u}
{m : Type u → Type v}
[monad m]
(m' : Type u → Type v)
[monad m'] :
monad_functor m m' (except_t ε m) (except_t ε m')
Equations
- except_t.monad_functor m' = {monad_map := except_t.monad_map _inst_2}
@[class]
An implementation of MonadError
Instances of this typeclass
Instances of other typeclasses for monad_except
- monad_except.has_sizeof_inst
@[protected]
def
monad_except.orelse
{ε : Type u}
{m : Type v → Type w}
[monad_except ε m]
{α : Type v}
(t₁ t₂ : m α) :
m α
Equations
- monad_except.orelse t₁ t₂ = monad_except.catch t₁ (λ (_x : ε), t₂)
@[protected, instance]
def
except_t.monad_except
(m : Type u_1 → Type u_2)
(ε : out_param (Type u_1))
[monad m] :
monad_except ε (except_t ε m)
Equations
- except_t.monad_except m ε = {throw := λ (α : Type u_1), except_t.mk ∘ has_pure.pure ∘ except.error, catch := except_t.catch _inst_1}
@[class]
structure
monad_except_adapter
(ε ε' : out_param (Type u))
(m m' : Type u → Type v) :
Type (max (u+1) v)
Adapt a monad stack, changing its top-most error type.
Note: This class can be seen as a simplification of the more "principled" definition
class monad_except_functor (ε ε' : out_param (Type u)) (n n' : Type u → Type u) :=
(map {α : Type u} : (∀ {m : Type u → Type u} [monad m], except_t ε m α → except_t ε' m α) → n α → n' α)
Instances of this typeclass
Instances of other typeclasses for monad_except_adapter
- monad_except_adapter.has_sizeof_inst
@[protected, instance]
def
monad_except_adapter_trans
{ε ε' : Type u}
{m m' n n' : Type u → Type v}
[monad_except_adapter ε ε' m m']
[monad_functor m m' n n'] :
monad_except_adapter ε ε' n n'
Equations
- monad_except_adapter_trans = {adapt_except := λ (α : Type u) (f : ε → ε'), monad_functor_t.monad_map (λ (α : Type u), monad_except_adapter.adapt_except f)}
@[protected, instance]
def
except_t.monad_except_adapter
{ε ε' : Type u}
{m : Type u → Type v}
[monad m] :
monad_except_adapter ε ε' (except_t ε m) (except_t ε' m)
Equations
- except_t.monad_except_adapter = {adapt_except := λ (α : Type u), except_t.adapt}
@[protected, instance]
def
except_t.monad_run
(ε : Type u_1)
(m : Type u_1 → Type u_2)
(out : out_param (Type u_1 → Type u_2))
[monad_run out m] :
Equations
- except_t.monad_run ε m out = {run := λ (α : Type u_1), monad_run.run ∘ except_t.run}