def
Option.toMonad
{m : Type u_1 → Type u_2}
{α : Type u_1}
[inst : Monad m]
[inst : Alternative m]
:
Option α → m α
Equations
- Option.toMonad _fun_discr = match _fun_discr with | none => failure | some a => pure a
@[inline]
Equations
- Option.toBool _fun_discr = match _fun_discr with | some val => true | none => false
@[inline]
Equations
- Option.isSome _fun_discr = match _fun_discr with | some val => true | none => false
@[inline]
Equations
- Option.isNone _fun_discr = match _fun_discr with | some val => false | none => true
@[inline]
Equations
- Option.isEqSome _fun_discr _fun_discr = match _fun_discr, _fun_discr with | some a, b => a == b | none, x => false
@[inline]
Equations
- Option.bind _fun_discr _fun_discr = match _fun_discr, _fun_discr with | none, x => none | some a, b => b a
@[inline]
Equations
- Option.map f o = Option.bind o (some ∘ f)
Equations
- Option.instFunctorOption = { map := fun {α β} => Option.map, mapConst := fun {α β} => Option.map ∘ Function.const β }
@[inline]
Equations
- Option.all p _fun_discr = match _fun_discr with | some a => p a | none => true
@[inline]
Equations
- Option.any p _fun_discr = match _fun_discr with | some a => p a | none => false
@[macroInline]
Equations
- Option.orElse _fun_discr _fun_discr = match _fun_discr, _fun_discr with | some a, x => some a | none, b => b ()
Equations
- Option.instOrElseOption = { orElse := Option.orElse }
Equations
- instDecidableEqOption = [anonymous]
Equations
- instFunctorOption = { map := fun {α β} => Option.map, mapConst := fun {α β} => Option.map ∘ Function.const β }
Equations
- instAlternativeOption = Alternative.mk (fun {α} => none) fun {α} => Option.orElse
Equations
- liftOption _fun_discr = match _fun_discr with | some a => pure a | none => failure
@[inline]
Equations
- Option.tryCatch x handle = match x with | some val => x | none => handle ()
Equations
- instMonadExceptOfUnitOption = { throw := fun {α} x => none, tryCatch := fun {α} => Option.tryCatch }