@[inline]
Equations
- Except.map f (Except.error err) = Except.error err
- Except.map f (Except.ok v) = Except.ok (f v)
Instances For
@[inline]
def
ExceptT.bindCont
{ε : Type u}
{m : Type u → Type v}
[Monad m]
{α β : Type u}
(f : α → ExceptT ε m β)
:
Equations
- ExceptT.bindCont f (Except.ok a) = f a
- ExceptT.bindCont f (Except.error e) = pure (Except.error e)
Instances For
@[inline]
def
ExceptT.bind
{ε : Type u}
{m : Type u → Type v}
[Monad m]
{α β : Type u}
(ma : ExceptT ε m α)
(f : α → ExceptT ε m β)
:
ExceptT ε m β
Equations
- ma.bind f = ExceptT.mk (ma >>= ExceptT.bindCont f)
Instances For
@[inline]
def
ExceptT.map
{ε : Type u}
{m : Type u → Type v}
[Monad m]
{α β : Type u}
(f : α → β)
(x : ExceptT ε m α)
:
ExceptT ε m β
Equations
- ExceptT.map f x = ExceptT.mk do let a ← x match a with | Except.ok a => pure (Except.ok (f a)) | Except.error e => pure (Except.error e)
Instances For
@[inline]
def
ExceptT.tryCatch
{ε : Type u}
{m : Type u → Type v}
[Monad m]
{α : Type u}
(ma : ExceptT ε m α)
(handle : ε → ExceptT ε m α)
:
ExceptT ε m α
Equations
- ma.tryCatch handle = ExceptT.mk do let res ← ma match res with | Except.ok a => pure (Except.ok a) | Except.error e => handle e
Instances For
@[inline]
Equations
- ExceptT.adapt f x = ExceptT.mk (Except.mapError f <$> x)
Instances For
@[always_inline]
instance
instMonadExceptOfExceptT
(m : Type u → Type v)
(ε₁ ε₂ : Type u)
[MonadExceptOf ε₁ m]
:
MonadExceptOf ε₁ (ExceptT ε₂ m)
@[always_inline]
instance
instMonadExceptOfExceptTOfMonad
(m : Type u → Type v)
(ε : Type u)
[Monad m]
:
MonadExceptOf ε (ExceptT ε m)
Equations
- instMonadExceptOfExceptTOfMonad m ε = { throw := fun {α : Type ?u.26} (e : ε) => ExceptT.mk (pure (Except.error e)), tryCatch := fun {α : Type ?u.26} => ExceptT.tryCatch }
@[inline]
def
MonadExcept.orelse'
{ε : Type u}
{m : Type v → Type w}
[MonadExcept ε m]
{α : Type v}
(t₁ t₂ : m α)
(useFirstEx : Bool := true)
:
m α
Alternative orelse operator that allows to select which exception should be used.
The default is to use the first exception since the standard orelse
uses the second.
Instances For
def
liftExcept
{ε : Type u_1}
{m : Type u_2 → Type u_3}
{α : Type u_2}
[MonadExceptOf ε m]
[Pure m]
:
Except ε α → m α
Equations
- liftExcept (Except.ok a) = pure a
- liftExcept (Except.error a) = throw a
Instances For
instance
instMonadControlExceptTOfMonad
(ε : Type u)
(m : Type u → Type v)
[Monad m]
:
MonadControl m (ExceptT ε m)
Equations
- One or more equations did not get rendered due to their size.
tryFinally' x f
runsx
and then the "finally" computationf
. Whenx
succeeds witha : α
,f (some a)
is returned. Ifx
fails form
's definition of failure,f none
is returned. HencetryFinally'
can be thought of as performing the same role as afinally
block in an imperative programming language.
Instances
@[inline]
def
tryFinally
{m : Type u → Type v}
{α β : Type u}
[MonadFinally m]
[Functor m]
(x : m α)
(finalizer : m β)
:
m α
Execute x
and then execute finalizer
even if x
threw an exception
Instances For
@[always_inline]
instance
ExceptT.finally
{m : Type u → Type v}
{ε : Type u}
[MonadFinally m]
[Monad m]
:
MonadFinally (ExceptT ε m)
Equations
- One or more equations did not get rendered due to their size.