Equations
Equations
- Option.instBEq = { beq := Option.beqOption✝ }
@[inline]
def
Option.bindM
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_1}
[Monad m]
(f : α → m (Option β))
(o : Option α)
:
m (Option β)
Runs f
on o
's value, if any, and returns its result, or else returns none
.
Equations
- Option.bindM f (some a) = do let __do_lift ← f a pure __do_lift
- Option.bindM f o = pure none
@[inline]
def
Option.mapM
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_1}
[Monad m]
(f : α → m β)
(o : Option α)
:
m (Option β)
Runs a monadic function f
on an optional value.
If the optional value is none
the function is not called.
Equations
- Option.mapM f (some a) = do let __do_lift ← f a pure (some __do_lift)
- Option.mapM f o = pure none
@[inline]
Checks that an optional value satisfies a predicate p
or is none
.
Equations
- Option.all p (some val) = p val
- Option.all p none = true
@[inline]
Checks that an optional value is not none
and the value satisfies a predicate p
.
Equations
- Option.any p (some val) = p val
- Option.any p none = false
Equations
- Option.instOrElse = { orElse := Option.orElse }
instance
Option.instDecidableRelLt
{α : Type u_1}
{β : Type u_2}
(r : α → β → Prop)
[s : DecidableRel r]
:
@[simp]
@[simp]
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 → Rel r (Option.some a) (Option.some b)
- none {α : Type u_1} {β : Type u_2} {r : α → β → Prop} : Rel r Option.none Option.none
@[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 none = pure none
- Option.mapA f (some a) = some <$> f a
@[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.
@[inline]
def
Option.elimM
{m : Type u_1 → Type u_2}
{α β : 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 __do_lift.elim y z
@[simp]
@[simp]
Equations
- Option.instMin = { min := Option.min }
Equations
- Option.instMax = { max := Option.max }
Equations
- instLTOption = { lt := Option.lt fun (x1 x2 : α) => x1 < x2 }
Equations
- instLEOption = { le := Option.le fun (x1 x2 : α) => x1 ≤ x2 }
@[always_inline]
Equations
- instFunctorOption = { map := fun {α β : Type ?u.10} => Option.map, mapConst := fun {α β : Type ?u.10} => Option.map ∘ Function.const β }
@[always_inline]
Equations
- instAlternativeOption = Alternative.mk (fun {α : Type ?u.6} => none) fun {α : Type ?u.6} => Option.orElse
Equations
- liftOption (some val) = pure val
- liftOption none = failure
Equations
- instMonadExceptOfUnitOption = { throw := fun {α : Type ?u.7} (x : Unit) => none, tryCatch := fun {α : Type ?u.7} => Option.tryCatch }