@[inline]
Equations
- Except.pure a = Except.ok a
@[inline]
Equations
- Except.map f (Except.error err) = Except.error err
- Except.map f (Except.ok v) = Except.ok (f v)
@[inline]
Equations
- Except.mapError f (Except.error err) = Except.error (f err)
- Except.mapError f (Except.ok v) = Except.ok v
@[inline]
def
Except.bind
{ε : Type u}
{α : Type u_1}
{β : Type u_2}
(ma : Except ε α)
(f : α → Except ε β)
:
Except ε β
Equations
- (Except.error err).bind f = Except.error err
- (Except.ok v).bind f = f v
@[reducible, inline]
Equations
def
Except.orElseLazy
{ε : Type u}
{α : Type u_1}
(x : Except ε α)
(y : Unit → Except ε α)
:
Except ε α
Equations
- (Except.ok a).orElseLazy y = Except.ok a
- (Except.error a).orElseLazy y = y ()
@[always_inline]
Equations
Instances For
- ExceptT.finally
- ExceptT.instLawfulMonad
- ExceptT.instMonad
- ExceptT.instMonadFunctor
- ExceptT.instMonadLift
- ExceptT.instMonadLiftExcept
- Lake.instMonadLiftTExceptTOfMonadOfMonadExceptOf_lake
- Lean.Order.instCCPOExceptTOfMonadOfPartialOrder
- Lean.Order.instMonoBindExceptTOfCCPO
- Lean.Order.instPartialOrderExceptTOfMonad
- Lean.instMonadBacktrackExceptTOfMonad
- Lean.instMonadCacheExceptTOfMonad
- instInhabitedExceptTOfMonad
- instMonadControlExceptTOfMonad
- instMonadExceptOfExceptT
- instMonadExceptOfExceptTOfMonad
@[inline]
Equations
- ExceptT.mk x = x
@[inline]
Equations
- ExceptT.pure a = ExceptT.mk (pure (Except.ok a))
@[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)
@[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)
@[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)
@[inline]
Equations
- ExceptT.lift t = ExceptT.mk (Except.ok <$> t)
@[always_inline]
Equations
- ExceptT.instMonadLiftExcept = { monadLift := fun {α : Type ?u.29} (e : Except ε α) => ExceptT.mk (pure e) }
Equations
- ExceptT.instMonadLift = { monadLift := fun {α : Type ?u.27} => ExceptT.lift }
Equations
- ExceptT.instMonadFunctor = { monadMap := fun {α : Type ?u.25} (f : {β : Type ?u.25} → m β → m β) (x : ExceptT ε m α) => f x }
@[inline]
Equations
- ExceptT.adapt f x = ExceptT.mk (Except.mapError f <$> x)
@[always_inline]
instance
instMonadExceptOfExceptT
(m : Type u → Type v)
(ε₁ ε₂ : Type u)
[MonadExceptOf ε₁ m]
:
MonadExceptOf ε₁ (ExceptT ε₂ m)
Equations
- One or more equations did not get rendered due to their size.
@[always_inline]
instance
instMonadExceptOfExceptTOfMonad
(m : Type u → Type v)
(ε : Type u)
[Monad m]
:
MonadExceptOf ε (ExceptT ε m)
Equations
- instMonadExceptOfExceptTOfMonad m ε = { throw := fun {α : Type ?u.29} (e : ε) => ExceptT.mk (pure (Except.error e)), tryCatch := fun {α : Type ?u.29} => ExceptT.tryCatch }
Equations
- instMonadExceptOfExcept ε = { throw := fun {α : Type ?u.14} => Except.error, tryCatch := fun {α : Type ?u.14} => Except.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.
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
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
Equations
- tryFinally x finalizer = (fun (x : α × β) => x.fst) <$> tryFinally' x fun (x : Option α) => finalizer
@[always_inline]
@[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.