Skip to content

Commit 25660ee

Browse files
committed
add CCOpt.{some,none}
close #382
1 parent 1f92564 commit 25660ee

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/core/CCOpt.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ let equal f o1 o2 = match o1, o2 with
3737
| Some x, Some y -> f x y
3838

3939
let return x = Some x
40+
let some = return
41+
let none = None
4042

4143
let[@inline] flat_map f o = match o with
4244
| None -> None

src/core/CCOpt.mli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
3434
val return : 'a -> 'a t
3535
(** [return x] is a monadic return, that is [return x = Some x]. *)
3636

37+
val some : 'a -> 'a t
38+
(** Alias to {!return}.
39+
@since NEXT_RELEASE *)
40+
41+
val none : 'a t
42+
(** Alias to {!None}.
43+
@since NEXT_RELEASE *)
44+
3745
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
3846
(** [o >|= f] is the infix version of {!map}. *)
3947

0 commit comments

Comments
 (0)