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.decidable_eq
.
Try to use o.is_none
or o.is_some
instead.
@[instance]
@[instance]
filter p o
returns some a
if o
is some a
and p a
holds, otherwise none
.
Equations
- option.filter p o = o.bind (option.guard p)
Equations
- option.lift_or_get f (some a) (some b) = some (f a b)
- option.lift_or_get f (some a) none = some a
- option.lift_or_get f none (some b) = some b
- option.lift_or_get f none none = none
@[instance]
def
option.lift_or_get_comm
{α : Type u_1}
(f : α → α → α)
[h : is_commutative α f] :
is_commutative (option α) (option.lift_or_get f)
@[instance]
def
option.lift_or_get_assoc
{α : Type u_1}
(f : α → α → α)
[h : is_associative α f] :
is_associative (option α) (option.lift_or_get f)
@[instance]
def
option.lift_or_get_idem
{α : Type u_1}
(f : α → α → α)
[h : is_idempotent α f] :
is_idempotent (option α) (option.lift_or_get f)
@[instance]
def
option.lift_or_get_is_left_id
{α : Type u_1}
(f : α → α → α) :
is_left_id (option α) (option.lift_or_get f) none
@[instance]
def
option.lift_or_get_is_right_id
{α : Type u_1}
(f : α → α → α) :
is_right_id (option α) (option.lift_or_get f) none
inductive
option.rel
{α : Type u_1}
{β : Type u_2}
(r : α → β → Prop)
(a : option α)
(a_1 : option β) :
Prop
- 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
def
option.traverse
{F : Type u → Type v}
[applicative F]
{α : Type u_1}
{β : Type u}
(f : α → F β)
(a : option α) :
F (option β)
Equations
- option.traverse f (some x) = some <$> f x
- option.traverse f none = pure none
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.
def
option.mmap
{m : Type u → Type v}
[monad m]
{α : Type w}
{β : Type u}
(f : α → m β)
(o : option α) :
m (option β)
Map a monadic function f : α → m β
over an o : option α
, maybe producing a result.
Equations
- option.mmap f o = (option.map f o).maybe