package alba

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Option Monad

Optional values

include Module_types.MONAD with type 'a t = 'a option
type 'a t = 'a option

The type of the monad containing values of type 'a

val return : 'a -> 'a t

return a makes a monadic container containing the value a.

val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

m >>= f extracts the value a from the monadic container m and returns f a.

val (>=>) : ('a -> 'b t) -> ('b -> 'c t) -> 'a -> 'c t

f >=> g composition of the two monadic functions f and g.

f >=> g is equivalent to fun a -> f a >>= g.

val map : ('a -> 'b) -> 'a t -> 'b t

map f m maps the values in the monadic container m with the function f.

val join : 'a t t -> 'a t

Remove one level of container. join m is equivalent to mm >>= fun m -> m.

val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

f <*> m applies the function contained in f to the content of the monadic container m and injects the result into a new monadic container.

val to_list : 'a t -> 'a list
val use : 'a t -> 'b -> ('a -> 'b) -> 'b
val fold : 'z -> ('a -> 'z) -> 'a t -> 'z
val has : 'a t -> bool
val value : 'a t -> 'a
val of_bool : bool -> unit t
val iter : ('a -> unit) -> 'a t -> unit
val fold_interval : ('a -> int -> 'a t) -> 'a -> int -> int -> 'a t
val fold_array : ('a -> 'b -> int -> 'a t) -> 'a -> 'b array -> 'a t

fold_array f start arr folds the function f over the array arr with start value start.

The function f maps an element of type 'a, an element of the array with its position in the array into an element of type 'a.

OCaml

Innovation. Community. Security.