Equations
- Option.instDecidableEq = Option.decEqOption✝
Lifts an optional value to any Alternative
, sending none
to failure
.
Instances For
Equations
- Option.toMonad = Option.getM
Instances For
Runs f
on o
's value, if any, and returns its result, or else returns none
.
Equations
- Option.bindM f (some a) = do let __do_lift ← f a pure __do_lift
- Option.bindM f o = pure none
Instances For
Runs a monadic function f
on an optional value.
If the optional value is none
the function is not called.
Equations
- Option.mapM f (some a) = do let __do_lift ← f a pure (some __do_lift)
- Option.mapM f o = pure none
Instances For
Keeps an optional value only if it satisfies the predicate p
.
Equations
- Option.filter p (some val) = if p val = true then some val else none
- Option.filter p none = none
Instances For
Checks that an optional value satisfies a predicate p
or is none
.
Equations
- Option.all p (some val) = p val
- Option.all p none = true
Instances For
Checks that an optional value is not none
and the value satisfies a predicate p
.
Equations
- Option.any p (some val) = p val
- Option.any p none = false
Instances For
Equations
- Option.instDecidableRelLt r none (some val) = isTrue trivial
- Option.instDecidableRelLt r (some x_2) (some y) = s x_2 y
- Option.instDecidableRelLt r (some val) none = isFalse not_false
- Option.instDecidableRelLt r none none = isFalse not_false
Take a pair of options and if they are both some
, apply the given fn to produce an output.
Otherwise act like orElse
.
Equations
- Option.merge fn none none = none
- Option.merge fn (some x_2) none = some x_2
- Option.merge fn none (some y) = some y
- Option.merge fn (some x_2) (some y) = some (fn x_2 y)
Instances For
An elimination principle for Option
. It is a nondependent version of Option.recOn
.
Instances For
Two arguments failsafe function. Returns f a b
if the inputs are some a
and some b
, and
"does nothing" otherwise.
Equations
- Option.liftOrGet f none none = none
- Option.liftOrGet f (some x_2) none = some x_2
- Option.liftOrGet f none (some y) = some y
- Option.liftOrGet f (some x_2) (some y) = some (f x_2 y)
Instances For
Lifts a relation α → β → Prop
to a relation Option α → Option β → Prop
by just adding
none ~ none
.
- 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
Instances For
Like Option.mapM
but for applicative functors.
Equations
- Option.mapA f none = pure none
- Option.mapA f (some a) = some <$> f a
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.
Instances For
A monadic analogue of Option.elim
.
Equations
- Option.elimM x y z = do let __do_lift ← x __do_lift.elim y z
Instances For
Equations
- instFunctorOption = { map := fun {α β : Type ?u.10} => Option.map, mapConst := fun {α β : Type ?u.10} => Option.map ∘ Function.const β }
Equations
- instAlternativeOption = Alternative.mk (fun {α : Type ?u.6} => none) fun {α : Type ?u.6} => Option.orElse
Equations
- liftOption (some val) = pure val
- liftOption none = failure
Instances For
Equations
- instMonadExceptOfUnitOption = { throw := fun {α : Type ?u.7} (x : Unit) => none, tryCatch := fun {α : Type ?u.7} => Option.tryCatch }