Documentation

Std.Data.Option.Basic

@[inline]
def Option.elim {α : Type u_1} {β : Sort u_2} :
β(αβ) → β

An elimination principle for Option. It is a nondependent version of Option.recOn.

Instances For
@[simp]
theorem Option.mem_def {α : Type u_1} {a : α} {b : } :
a b b = some a
instance Option.instDecidableMemOptionInstMembershipOption {α : Type u_1} [] (j : α) (o : ) :
theorem Option.isNone_iff_eq_none {α : Type u_1} {o : } :
o = none
theorem Option.some_inj {α : Type u_1} {a : α} {b : α} :
some a = some b a = b
@[inline]
def Option.decidable_eq_none {α : Type u_1} {o : } :
Decidable (o = none)

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.

Instances For
instance Option.instForAllOptionDecidableForAllMemInstMembershipOption {α : Type u_1} {p : αProp} [] (o : ) :
Decidable ((a : α) → a op a)
instance Option.instForAllOptionDecidableExistsAndMemInstMembershipOption {α : Type u_1} {p : αProp} [] (o : ) :
Decidable (a, a o p a)
@[inline]
def Option.get {α : Type u} (o : ) :
α

Extracts the value a from an option that is known to be some a for some a.

Instances For
@[inline]
def Option.guard {α : Type u_1} (p : αProp) [] (a : α) :

guard p a returns some a if p a holds, otherwise none.

Instances For
@[inline]
def Option.toList {α : Type u_1} :
List α

Cast of Option to List. Returns [a] if the input is some a, and [] if it is none.

Instances For
@[inline]
def Option.toArray {α : Type u_1} :

Cast of Option to Array. Returns [a] if the input is some a, and [] if it is none.

Instances For
def Option.liftOrGet {α : Type u_1} (f : ααα) :

Two arguments failsafe function. Returns f a b if the inputs are some a and some b, and "does nothing" otherwise.

Instances For
inductive Option.Rel {α : Type u_1} {β : Type u_2} (r : αβProp) :
Prop
• some: ∀ {α : Type u_1} {β : Type u_2} {r : αβProp} {a : α} {b : β}, r a bOption.Rel r (some a) (some b)

If a ~ b, then some a ~ some b

• none: ∀ {α : Type u_1} {β : Type u_2} {r : αβProp}, Option.Rel r none none

none ~ none

Lifts a relation α → β → Prop to a relation Option α → Option β → Prop by just adding none ~ none.

Instances For
@[inline]
def Option.pbind {α : Type u_1} {β : Type u_2} (x : ) :
((a : α) → a x) →

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.

Instances For
@[inline]
def Option.pmap {α : Type u_1} {β : Type u_2} {p : αProp} (f : (a : α) → p aβ) (x : ) :
((a : α) → a xp a) →

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.

Instances For
@[inline]
def Option.join {α : Type u_1} (x : Option ()) :

Flatten an Option of Option, a specialization of joinM.

Instances For
@[inline]
def Option.forM {m : TypeType u_1} {α : Type u_2} [Pure m] :
(α) →

Map a monadic function which returns Unit over an Option.

Instances For
instance Option.instForMOption {m : TypeType u_1} {α : Type u_2} :
ForM m () α
instance Option.instForIn'OptionInferInstanceMembershipInstMembershipOption {m : Type u_1 → Type u_2} {α : Type u_3} :
ForIn' m () α inferInstance
@[inline]
def Option.mapA {m : Type u_1 → Type u_2} [] {α : Type u_3} {β : Type u_1} (f : αm β) :
m ()

Like Option.mapM but for applicative functors.

Instances For
@[inline]
def Option.sequence {m : Type u → Type u_1} [] {α : Type u} :
Option (m α)m ()

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.

Instances For
@[inline]
def Option.elimM {m : Type u_1 → Type u_2} {α : Type u_1} {β : Type u_1} [] (x : m ()) (y : m β) (z : αm β) :
m β

A monadic analogue of Option.elim.

Instances For
@[inline]
def Option.getDM {m : Type u_1 → Type u_2} {α : Type u_1} [] (x : ) (y : m α) :
m α

A monadic analogue of Option.getD.

Instances For