extlib

A complete yet small extension for OCaml standard library (reduced, recommended)
Library extLib
Module Option
val may : ( 'a -> unit ) -> 'a option -> unit

may f (Some x) calls f x and may f None does nothing.

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

map f (Some x) returns Some (f x) and map None returns None.

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

default x (Some v) returns v and default x None returns x.

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

map_default f x (Some v) returns f v and map_default f x None returns x.

val is_none : 'a option -> bool

is_none None returns true otherwise it returns false.

val is_some : 'a option -> bool

is_some (Some x) returns true otherwise it returns false.

val get : 'a option -> 'a

get (Some x) returns x and get None raises No_value.

exception No_value

Raised when calling get None.