Equations
Equations
- Option.instBEq = { beq := Option.beqOption✝ }
Lifts an optional value to any Alternative
, sending none
to failure
.
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
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
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
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
Equations
- Option.instOrElse = { orElse := Option.orElse }
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 → Rel r (Option.some a) (Option.some b)
- none {α : Type u_1} {β : Type u_2} {r : α → β → Prop} : Rel r Option.none Option.none
Like Option.mapM
but for applicative functors.
Equations
- Option.mapA f none = pure none
- Option.mapA f (some a) = some <$> f a
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.
A monadic analogue of Option.elim
.
Equations
- Option.elimM x y z = do let __do_lift ← x __do_lift.elim y z
Equations
- Option.instMin = { min := Option.min }
Equations
- Option.instMax = { max := Option.max }
Equations
- instLTOption = { lt := Option.lt fun (x1 x2 : α) => x1 < x2 }
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
Equations
- instMonadExceptOfUnitOption = { throw := fun {α : Type ?u.7} (x : Unit) => none, tryCatch := fun {α : Type ?u.7} => Option.tryCatch }