module BatOption:Functions for the option type.sig..end
Options are an Ocaml standard type that can be either None (undefined)
or Some x where x can be any value. Options are widely used in Ocaml
to represent undefined values (a little like NULL in C, but in a type
and memory safe way). This module adds some functions for working with
options.
Author(s): Nicolas Cannasse, David Teller
type'at ='a option
val may : ('a -> unit) -> 'a option -> unitmay f (Some x) calls f x and may f None does nothing.val map : ('a -> 'b) -> 'a option -> 'b optionmap f (Some x) returns Some (f x) and map f None returns None.val bind : ('a -> 'b option) -> 'a option -> 'b optionbind f (Some x) returns f x and bind f None returns None.val default : 'a -> 'a option -> 'adefault x (Some v) returns v and default x None returns x.val map_default : ('a -> 'b) -> 'b -> 'a option -> 'bmap_default f x (Some v) returns f v and map_default f x None
returns x.val is_none : 'a option -> boolis_none None returns true otherwise it returns false.val is_some : 'a option -> boolis_some (Some x) returns true otherwise it returns false.val get : 'a option -> 'aget (Some x) returns x and get None raises No_value.val get_exn : 'a option -> exn -> 'aget_exn (Some x) e returns x and get_exn None e raises e.val enum : 'a option -> 'a BatEnum.tenum (Some x) returns the singleton x, while enum None returns
the empty enumerationval of_enum : 'a BatEnum.t -> 'a optionof_enum e consumes the first element of e, if it exists, and
returns Some e. If e is empty, return Noneexception No_value
get None.module Monad:sig..end
val print : ('a BatInnerIO.output -> 'b -> unit) ->
'a BatInnerIO.output -> 'b t -> unitval t_printer : 'a BatValue_printer.t -> 'a t BatValue_printer.tval maybe_printer : 'a BatValue_printer.t -> 'a t BatValue_printer.tmodule Labels:sig..end