CCKlist infix operators for monad, applicative...

This commit is contained in:
Simon Cruanes 2014-07-18 02:34:52 +02:00
parent 05453c3ce8
commit a27e252cf1
2 changed files with 18 additions and 0 deletions

View file

@ -230,6 +230,15 @@ let rec merge cmp l1 l2 () = match l1(), l2() with
then `Cons (x1, 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} *)
let rec _to_rev_list acc l = match l() with

View file

@ -115,6 +115,15 @@ val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val merge : 'a ord -> 'a t -> 'a t -> 'a t
(** 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} *)
module type MONAD = sig
type 'a t