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
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 = a.elim 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 ⋯
Instances For
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
instance
Option.liftOrGet_isId
{α : Type u_1}
(f : α → α → α)
:
Std.LawfulIdentity (Option.liftOrGet f) none
Equations
- ⋯ = ⋯
Convert undef to none to make an LOption into an Option.
Equations
- x.toOption = match x with | Lean.LOption.some a => some a | x => none