mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
CCKlist infix operators for monad, applicative...
This commit is contained in:
parent
05453c3ce8
commit
a27e252cf1
2 changed files with 18 additions and 0 deletions
|
|
@ -230,6 +230,15 @@ let rec merge cmp l1 l2 () = match l1(), l2() with
|
||||||
then `Cons (x1, merge cmp l1' l2)
|
then `Cons (x1, merge cmp l1' l2)
|
||||||
else `Cons (x2, merge cmp l1 l2')
|
else `Cons (x2, merge cmp l1 l2')
|
||||||
|
|
||||||
|
(** {2 Implementations} *)
|
||||||
|
|
||||||
|
let return x () = `Cons (x, nil)
|
||||||
|
let pure = return
|
||||||
|
let (>>=) xs f = flat_map f xs
|
||||||
|
let (>|=) xs f = map f xs
|
||||||
|
|
||||||
|
let (<*>) fs xs = product_with (fun f x -> f x) fs xs
|
||||||
|
|
||||||
(** {2 Conversions} *)
|
(** {2 Conversions} *)
|
||||||
|
|
||||||
let rec _to_rev_list acc l = match l() with
|
let rec _to_rev_list acc l = match l() with
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,15 @@ val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
|
||||||
val merge : 'a ord -> 'a t -> 'a t -> 'a t
|
val merge : 'a ord -> 'a t -> 'a t -> 'a t
|
||||||
(** Merge two sorted iterators into a sorted iterator *)
|
(** Merge two sorted iterators into a sorted iterator *)
|
||||||
|
|
||||||
|
(** {2 Implementations}
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
val return : 'a -> 'a t
|
||||||
|
val pure : 'a -> 'a t
|
||||||
|
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
||||||
|
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
|
||||||
|
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
|
||||||
|
|
||||||
(** {2 Monadic Operations} *)
|
(** {2 Monadic Operations} *)
|
||||||
module type MONAD = sig
|
module type MONAD = sig
|
||||||
type 'a t
|
type 'a t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue