diff --git a/core/CCKList.ml b/core/CCKList.ml index 964bdb1f..161ef36f 100644 --- a/core/CCKList.ml +++ b/core/CCKList.ml @@ -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 diff --git a/core/CCKList.mli b/core/CCKList.mli index 2e244712..bd420ea4 100644 --- a/core/CCKList.mli +++ b/core/CCKList.mli @@ -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