diff --git a/README.md b/README.md index 377b6852..6083c7e0 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ structures comprise (some modules in `misc/`, some other in `core/`): - `CCPersistentHashtbl`, a semi-persistent hashtable (similar to [persistent arrays](https://www.lri.fr/~filliatr/ftp/ocaml/ds/parray.ml.html)) - `CCVector`, a growable array (pure OCaml, no C) with mutability annotations - `CCGen` and `CCSequence`, generic iterators structures (with structural types so they can be defined in several places). Now also in their own repository and opam packages (`gen` and `sequence`). -- `CCKlist`, a persistent iterator structure (akin to a lazy list) -- `CCList`, functions and lists including tail-recursive implementations of `map` and `append` and many other utilities +- `CCKList`, a persistent iterator structure (akin to a lazy list) +- `CCList`, functions on lists, including tail-recursive implementations of `map` and `append` and many other things - `CCArray`, utilities on arrays and slices - `CCLinq`, high-level query language over collections - `CCMultimap` and `CCMultiset`, functors defining persistent structures @@ -62,14 +62,14 @@ structures comprise (some modules in `misc/`, some other in `core/`): - `CCInt` - `CCString` (basic string operations) - `CCPair` (cartesian products) - - `CCOpt` (options) + - `CCOpt` (options, very useful) - `CCFun` (function combinators) - `CCBool` - `CCOrd` (combinators for total orderings) - `CCRandom` (combinators for random generators) - `CCPrint` (printing combinators) - `CCHash` (hashing combinators) - - `CCError` (monadic error handling) + - `CCError` (monadic error handling, very useful) ### String diff --git a/core/CCOpt.ml b/core/CCOpt.ml index 6ed63e5f..07be2451 100644 --- a/core/CCOpt.ml +++ b/core/CCOpt.ml @@ -64,6 +64,8 @@ let flat_map f o = match o with | None -> None | Some x -> f x +let pure x = Some x + let (<*>) f x = match f, x with | None, _ | _, None -> None diff --git a/core/CCOpt.mli b/core/CCOpt.mli index a8d60d6e..2c0e1d4f 100644 --- a/core/CCOpt.mli +++ b/core/CCOpt.mli @@ -68,6 +68,9 @@ val sequence_l : 'a t list -> 'a list t (** {2 Applicative} *) +val pure : 'a -> 'a t +(** Alias to {!return} *) + val (<*>) : ('a -> 'b) t -> 'a t -> 'b t val (<$>) : ('a -> 'b) -> 'a t -> 'b t