mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
feat(opt): add bind
This commit is contained in:
parent
1dcc529623
commit
bf8db5dcff
2 changed files with 8 additions and 0 deletions
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
type 'a t = 'a option
|
type 'a t = 'a option
|
||||||
|
|
||||||
|
let bind f = function
|
||||||
|
| None -> None
|
||||||
|
| Some x -> f x
|
||||||
|
|
||||||
let map f = function
|
let map f = function
|
||||||
| None -> None
|
| None -> None
|
||||||
| Some x -> Some (f x)
|
| Some x -> Some (f x)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
type +'a t = 'a option
|
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
|
val map : ('a -> 'b) -> 'a t -> 'b t
|
||||||
(** Transform the element inside, if any. *)
|
(** Transform the element inside, if any. *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue