package mechaml

  1. Overview
  2. Docs

Helpers for the option Monad

Monadic operations

val return : 'a -> 'a option
val bind : 'a option -> ('a -> 'b option) -> 'b option
val join : 'a option option -> 'a option
val map : ('a -> 'b) -> 'a option -> 'b option
val map_pair : ('a option * 'b option) -> ('a -> 'b -> 'c) -> 'c option

Apply a two arguments function to a pair of optionals : if one of the component is None, the result is None, otherwise map2 (Some x, Some y) f is Some (f x y)

val default : 'a option -> 'a -> 'a

Return the content of an optional, or the given default value if the first argument is None.

module Infix : sig ... end
OCaml

Innovation. Community. Security.