Module Stdlib320.Option

A module containing basic operations for options.

val is_none : 'a option -> bool

is_none o is

  • true if o = Some x
  • false if o = None
val is_some : 'a option -> bool

is_some o is equivalent to not (is_none o)

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

Mapping function for options. It applies a function to the value of the option if the option is not None. map f o is

  • Some (f x) if o = Some x
  • None if o = None
val bind : 'a option -> ('a -> 'b option) -> 'b option

Monadic bind for options. It "does something" to the value of the option if it is not None, and passes along the None otherwise. bind o f is

  • f x if o = Some x
  • None if o = None

Printers

val sprint : ('a -> string) -> 'a option -> string
val print : ('a -> string) -> 'a option -> unit