def
Option.toMonad
{m : Type u_1 → Type u_2}
{α : Type u_1}
[Monad m]
[Alternative m]
:
Option α → m α
Equations
- Option.toMonad x = match x with | none => failure | some a => pure a
Instances For
@[inline]
Equations
- Option.isEqSome x✝ x = match x✝, x with | some a, b => a == b | none, x => false
Instances For
@[inline]
Equations
- Option.bind x✝ x = match x✝, x with | none, x => none | some a, b => b a
Instances For
Equations
- One or more equations did not get rendered due to their size.
Take a pair of options and if they are both some
, apply the given fn to produce an output.
Otherwise act like orElse
.
Equations
Instances For
Equations
- instDecidableEqOption = decEqOption✝
@[always_inline]
Equations
- instFunctorOption = { map := fun {α β : Type u_1} => Option.map, mapConst := fun {α β : Type u_1} => Option.map ∘ Function.const β }
@[always_inline]
Equations
- instAlternativeOption = Alternative.mk (fun {α : Type u_1} => none) fun {α : Type u_1} => Option.orElse
Equations
- liftOption x = match x with | some a => pure a | none => failure
Instances For
Equations
- instMonadExceptOfUnitOption = { throw := fun {α : Type u_1} (x : Unit) => none, tryCatch := fun {α : Type u_1} => Option.tryCatch }