feat(opt): add bind

This commit is contained in:
Fardale 2020-01-06 16:15:52 +01:00
parent 1dcc529623
commit bf8db5dcff
2 changed files with 8 additions and 0 deletions

View file

@ -4,6 +4,10 @@
type 'a t = 'a option
let bind f = function
| None -> None
| Some x -> f x
let map f = function
| None -> None
| Some x -> Some (f x)

View file

@ -4,6 +4,10 @@
type +'a t = 'a option
val bind : ('a -> 'b t) -> 'a t -> 'b t
(** [bind f o] if [o] is [Some v] then [f v] else [None]
@since NEXT_RELEASE *)
val map : ('a -> 'b) -> 'a t -> 'b t
(** Transform the element inside, if any. *)