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
Equations
o = none
is decidable even if the wrapped type does not have decidable equality.
This is not an instance because it is not definitionally equal to instance : DecidableEq Option
.
Try to use o.isNone
or o.isSome
instead.
Equations
- Option.decidable_eq_none = decidable_of_decidable_of_iff (_ : Option.isNone o = true ↔ o = none)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
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
- 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
Lifts a relation α → β → Prop
to a relation Option α → Option β → Prop
by just adding
none ~ none
.
Instances For
Partial bind. If for some x : Option α
, f : Π (a : α), a ∈ x → Option β
is a
partial function defined on a : α
giving an Option β
, where some a = x
,
then pbind x f h
is essentially the same as bind x f
but is defined only when all x = some a
, using the proof to apply f
.
Equations
Instances For
Partial map. If f : Π a, p a → β
is a partial function defined on a : α
satisfying p
,
then pmap f x h
is essentially the same as map f x
but is defined only when all members of x
satisfy p
, using the proof to apply f
.
Equations
- Option.pmap f x x = match x, x with | none, x => none | some a, H => some (f a (Option.pmap.proof_1 a H))
Instances For
Flatten an Option
of Option
, a specialization of joinM
.
Equations
- Option.join x = Option.bind x id
Instances For
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
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
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
A monadic analogue of Option.getD
.
Equations
- Option.getDM x y = match x with | some a => pure a | none => y