Equations
- instToBoolOption = { toBool := Option.toBool }
@[inline]
Equations
- OptionT.run x = x
Equations
- OptionT.mk x = x
@[inline]
def
OptionT.bind
{m : Type u → Type v}
[inst : Monad m]
{α : Type u}
{β : Type u}
(x : OptionT m α)
(f : α → OptionT m β)
:
OptionT m β
Equations
- OptionT.bind x f = OptionT.mk do let a ← x match a with | some a => f a | none => pure none
@[inline]
Equations
- OptionT.pure a = OptionT.mk (pure (some a))
@[inline]
def
OptionT.orElse
{m : Type u → Type v}
[inst : Monad m]
{α : Type u}
(x : OptionT m α)
(y : Unit → OptionT m α)
:
OptionT m α
Equations
- OptionT.orElse x y = OptionT.mk do let a ← x match a with | some a => pure (some a) | x => y ()
@[inline]
Equations
- OptionT.fail = OptionT.mk (pure none)
instance
OptionT.instAlternativeOptionT
{m : Type u → Type v}
[inst : Monad m]
:
Alternative (OptionT m)
Equations
- OptionT.instAlternativeOptionT = Alternative.mk (fun {α} => OptionT.fail) fun {α} => OptionT.orElse
@[inline]
Equations
- OptionT.lift x = OptionT.mk do let a ← x pure (some a)
@[inline]
def
OptionT.tryCatch
{m : Type u → Type v}
[inst : Monad m]
{α : Type u}
(x : OptionT m α)
(handle : Unit → OptionT m α)
:
OptionT m α
Equations
- OptionT.tryCatch x handle = OptionT.mk do let discr ← x match discr with | some a => pure (some a) | x => handle ()
instance
OptionT.instMonadExceptOfUnitOptionT
{m : Type u → Type v}
[inst : Monad m]
:
MonadExceptOf Unit (OptionT m)
Equations
- OptionT.instMonadExceptOfUnitOptionT = { throw := fun {α} x => OptionT.fail, tryCatch := fun {α} => OptionT.tryCatch }
instance
OptionT.instMonadExceptOfOptionT
{m : Type u → Type v}
(ε : Type u)
[inst : Monad m]
[inst : MonadExceptOf ε m]
:
MonadExceptOf ε (OptionT m)
Equations
- OptionT.instMonadExceptOfOptionT ε = { throw := fun {α} e => OptionT.mk (throwThe ε e), tryCatch := fun {α} x handle => OptionT.mk (tryCatchThe ε x handle) }
@[inline]
Equations
- OptionM.run x = x
instance
instMonadControlOptionT
{m : Type u_1 → Type u_2}
[inst : Monad m]
:
MonadControl m (OptionT m)
Equations
- instMonadControlOptionT = { stM := Option, liftWith := fun {α} f => liftM (f fun {β} x => OptionT.run x), restoreM := fun {α} x => x }
Equations
- liftOption x = match x with | some a => pure a | none => failure