@[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, instance]
Equations
@[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 = ⟨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) = pure (except.error e)
@[protected]
def
except_t.lift
{ε : Type u}
{m : Type u → Type v}
[monad m]
{α : Type u}
(t : m α) :
except_t ε m α
Equations
- except_t.lift t = ⟨except.ok <$> t⟩
@[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]
def
except_t.catch
{ε : Type u}
{m : Type u → Type v}
[monad m]
{α : Type u}
(ma : except_t ε m α)
(handle : ε → except_t ε m α) :
except_t ε m α
@[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}
@[protected, instance]
Equations
@[protected]
Equations
- except_t.adapt f = λ (x : except_t ε m α), ⟨except.map_error f <$> x.run⟩
@[class]
- throw : Π {α : Type ?}, ε → m α
- catch : Π {α : Type ?}, m α → (ε → m α) → m α
An implementation of MonadError
@[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₂ = 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 ∘ 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_except : Π {α : Type ?}, (ε → ε') → m α → m' α
Adapt a monad stack, changing its top-most error type.
Note: This class can be seen as a simplification of the more "principled" definition
@[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_map (λ (α : Type u), 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), run ∘ except_t.run}