Extra definitions on Option
#
This file defines more operations involving Option α
. Lemmas about them are located in other
files under Mathlib.Data.Option
.
Other basic operations on Option
are defined in the core library.
def
Option.traverse
{F : Type u → Type v}
[Applicative F]
{α : Type u_1}
{β : Type u}
(f : α → F β)
:
Traverse an object of Option α
with a function f : α → F β
for an applicative F
.
Equations
- Option.traverse f x = match x with | none => pure none | some x => some <$> f x
Instances For
@[deprecated Option.getDM]
def
Option.getDM'
{m : Type u_1 → Type u_2}
{α : Type u_1}
[Monad m]
(x : m (Option α))
(y : m α)
:
m α
Equations
- Option.getDM' x y = do let __do_lift ← x Option.getDM __do_lift y
Instances For
An elimination principle for Option
. It is a nondependent version of Option.rec
.
Equations
- Option.elim' b f x = match x with | some a => f a | none => b
Instances For
@[simp]
theorem
Option.elim'_none
{α : Type u_1}
{β : Type u_2}
(b : β)
(f : α → β)
:
Option.elim' b f none = b
@[simp]
theorem
Option.elim'_some
{α : Type u_1}
{β : Type u_2}
{a : α}
(b : β)
(f : α → β)
:
Option.elim' b f (some a) = f a
theorem
Option.elim'_eq_elim
{α : Type u_3}
{β : Type u_4}
(b : β)
(f : α → β)
(a : Option α)
:
Option.elim' b f a = Option.elim a b f
@[inline]
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 Option.decidableEq
.
Try to use o.isNone
or o.isSome
instead.
Equations
- Option.decidableEqNone = 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.
@[reducible]
Inhabited get
function. Returns a
if the input is some a
, otherwise returns default
.
Equations
- Option.iget x = match x with | some x => x | none => default
Instances For
@[simp]
Equations
- (_ : Std.Commutative (Option.liftOrGet f)) = (_ : Std.Commutative (Option.liftOrGet f))
Equations
- (_ : Std.Associative (Option.liftOrGet f)) = (_ : Std.Associative (Option.liftOrGet f))
Equations
- (_ : Std.IdempotentOp (Option.liftOrGet f)) = (_ : Std.IdempotentOp (Option.liftOrGet f))
instance
Option.liftOrGet_isId
{α : Type u_1}
(f : α → α → α)
:
Std.LawfulIdentity (Option.liftOrGet f) none
Equations
- (_ : Std.LawfulIdentity (Option.liftOrGet f) none) = (_ : Std.LawfulIdentity (Option.liftOrGet f) none)
Convert undef
to none
to make an LOption
into an Option
.
Equations
- Lean.LOption.toOption x = match x with | Lean.LOption.some a => some a | x => none