instance
Option.instDecidableEqOption :
{α : Type u_1} → [inst : DecidableEq α] → DecidableEq (Option α)
Equations
- Option.instDecidableEqOption = Option.decEqOption✝
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.
@[simp]
@[simp]
theorem
Option.map_some'
{α : Type u_1}
{β : Type u_2}
(a : α)
(f : α → β)
:
Option.map f (some a) = some (f a)
@[simp]
theorem
Option.none_bind
{α : Type u_1}
{β : Type u_2}
(f : α → Option β)
:
Option.bind none f = none
@[simp]
theorem
Option.some_bind
{α : Type u_1}
{β : Type u_2}
(a : α)
(f : α → Option β)
:
Option.bind (some a) f = f a
@[inline]
An elimination principle for Option
. It is a nondependent version of Option.recOn
.
Equations
- Option.elim x✝¹ x✝ x = match x✝¹, x✝, x with | some x, x_1, f => f x | none, y, x => y
Instances For
@[inline]
Extracts the value a
from an option that is known to be some a
for some a
.
Equations
- Option.get x✝ x = match x✝, x with | some x, x_1 => x
Instances For
Lifts a relation α → β → Prop
to a relation Option α → Option β → Prop
by just adding
none ~ none
.
- some: ∀ {α : Type u_1} {β : Type u_2} {r : α → β → Prop} {a : α} {b : β}, r a b → Option.Rel r (some a) (some b)
- none: ∀ {α : Type u_1} {β : Type u_2} {r : α → β → Prop}, Option.Rel r none none
Instances For
@[inline]
Flatten an Option
of Option
, a specialization of joinM
.
Equations
- Option.join x = Option.bind x id
Instances For
@[inline]
def
Option.mapA
{m : Type u_1 → Type u_2}
[Applicative m]
{α : Type u_3}
{β : Type u_1}
(f : α → m β)
:
Like Option.mapM
but for applicative functors.
Equations
- Option.mapA f x = match x with | none => pure none | some x => some <$> f x
Instances For
@[inline]
If you maybe have a monadic computation in a [Monad m]
which produces a term of type α
, then
there is a naturally associated way to always perform a computation in m
which maybe produces a
result.
Equations
- Option.sequence x = match x with | none => pure none | some fn => some <$> fn
Instances For
@[inline]
def
Option.elimM
{m : Type u_1 → Type u_2}
{α : Type u_1}
{β : Type u_1}
[Monad m]
(x : m (Option α))
(y : m β)
(z : α → m β)
:
m β
A monadic analogue of Option.elim
.
Equations
- Option.elimM x y z = do let __do_lift ← x Option.elim __do_lift y z
Instances For
@[inline]
A monadic analogue of Option.getD
.
Equations
- Option.getDM x y = match x with | some a => pure a | none => y
Instances For
@[simp]
@[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 }