add CCOpt.{some,none}

close #382
This commit is contained in:
Simon Cruanes 2021-06-19 18:43:17 -04:00
parent 1f92564f83
commit 25660ee2c1
2 changed files with 10 additions and 0 deletions

View file

@ -37,6 +37,8 @@ let equal f o1 o2 = match o1, o2 with
| Some x, Some y -> f x y
let return x = Some x
let some = return
let none = None
let[@inline] flat_map f o = match o with
| None -> None

View file

@ -34,6 +34,14 @@ val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val return : 'a -> 'a t
(** [return x] is a monadic return, that is [return x = Some x]. *)
val some : 'a -> 'a t
(** Alias to {!return}.
@since NEXT_RELEASE *)
val none : 'a t
(** Alias to {!None}.
@since NEXT_RELEASE *)
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
(** [o >|= f] is the infix version of {!map}. *)