Skip to content

Commit

Permalink
add CCOpt.{some,none}
Browse files Browse the repository at this point in the history
close #382
  • Loading branch information
c-cube committed Jun 19, 2021
1 parent 1f92564 commit 25660ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/CCOpt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/core/CCOpt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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}. *)

Expand Down

0 comments on commit 25660ee

Please sign in to comment.