Preface_stdlib.OptionImplementation for Option.t.
Option.t allows to explicitly describe the presence (Some x) or absence (None) of a value. This allows, among other things, the transformation of partial functions into total functions, and forces the explicit handling of the case where None is returned.
The set of concrete implementations for Option.t.
module Functor : Preface_specs.FUNCTOR with type 'a t = 'a tOption.t implements Preface_specs.APPLICATIVE and introduces an interface to define Preface_specs.TRAVERSABLE using Option as an iterable structure.
module Applicative :
Preface_specs.Traversable.API_OVER_APPLICATIVE with type 'a t = 'a tmodule Alternative : Preface_specs.ALTERNATIVE with type 'a t = 'a tmodule Selective : Preface_specs.SELECTIVE with type 'a t = 'a tOption.t implements Preface_specs.MONAD and introduces an interface to define Preface_specs.TRAVERSABLE using Option as an iterable structure.
module Monad : Preface_specs.Traversable.API_OVER_MONAD with type 'a t = 'a tmodule Monad_plus : Preface_specs.MONAD_PLUS with type 'a t = 'a tmodule Foldable : Preface_specs.FOLDABLE with type 'a t = 'a tmodule Invariant : Preface_specs.INVARIANT with type 'a t = 'a tOption is the Free monoid over a semigroup so wrapping a Preface_specs.SEMIGROUP into an Option gives us a Preface_specs.MONOID with None as a neutral element.
module Monoid
(M : Preface_specs.SEMIGROUP) :
Preface_specs.MONOID with type t = M.t tAdditional functions to facilitate practical work with Option.t.
val pure : 'a -> 'a tCreate a value from 'a to 'a Option.t.
val pp :
(Stdlib.Format.formatter -> 'a -> unit) ->
Stdlib.Format.formatter ->
'a t ->
unitFormatter for pretty-printing for Option.t.
val if_ : 'a Predicate.t -> 'a -> 'a tis_ p x produces Some x if p x is true, otherwise, it produces None.
val unless : 'a Predicate.t -> 'a -> 'a tis_ p x produces Some x if p x is false, otherwise, it produces None.