Module Option
Module implementing basic combinators for OCaml option type. It tries follow closely the style of OCaml standard library.
Actually, some operations have the same name as List ones: they actually are similar considering 'a option as a type of lists with at most one element.
- val equal : ('a -> 'a -> bool) -> 'a option -> 'a option -> bool
- equal f x ylifts the equality predicate- fto option types. That is, if both- xand- yare- Nonethen it returns- true, if they are both- Some _then- fis called. Otherwise it returns- false.
- val bind : 'a option -> ('a -> 'b option) -> 'b option
- bind x fis- f yif- xis- Some yand- Noneotherwise
- val flatten : 'a option option -> 'a option
- flatten xis- Some yif- xis- Some (Some y)and- Noneotherwise.
- val append : 'a option -> 'a option -> 'a option
- append x yis the first element of the concatenation of- xand- yseen as lists. In other words,- append (Some a) yis- Some a,- append None (Some b)is- Some b, and- append None Noneis- None.
"Iterators"
- val iter : ('a -> unit) -> 'a option -> unit
- iter f xexecutes- f yif- xequals- Some y. It does nothing otherwise.
- val iter2 : ('a -> 'b -> unit) -> 'a option -> 'b option -> unit
- iter2 f x yexecutes- f z wif- xequals- Some zand- yequals- Some w. It does nothing if both- xand- yare- None.- raises Heterogeneous
- otherwise. 
 
- val map : ('a -> 'b) -> 'a option -> 'b option
- map f xis- Noneif- xis- Noneand- Some (f y)if- xis- Some y.
- val fold_left : ('b -> 'a -> 'b) -> 'b -> 'a option -> 'b
- fold_left f a xis- f a yif- xis- Some y, and- aotherwise.
- val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b option -> 'c option -> 'a
- fold_left2 f a x yis- f z wif- xis- Some zand- yis- Some w. It is- aif both- xand- yare- None.- raises Heterogeneous
- otherwise. 
 
- val fold_right : ('a -> 'b -> 'b) -> 'a option -> 'b -> 'b
- fold_right f x ais- f y aif- xis- Some y, and- aotherwise.
- val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b option -> 'a * 'c option
- fold_left_map f a xis- a, f yif- xis- Some y, and- aotherwise.
More Specific Operations
- val lift : ('a -> 'b) -> 'a option -> 'b option
- liftis the same as- map.
- val lift_right : ('a -> 'b -> 'c) -> 'a -> 'b option -> 'c option
- lift_right f a xis- Some (f a y)if- xis- Some y, and- Noneotherwise.
Smart operations
module Smart : sig ... endOperations with Lists
module List : sig ... end