From 633ded75c29970ed8aaaab3bfc6a648303058fc4 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 16 Jul 2014 18:08:57 +0200 Subject: [PATCH] make CCList an applicative instance --- core/CCList.ml | 2 ++ core/CCList.mli | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/CCList.ml b/core/CCList.ml index 2fca2327..b95942ed 100644 --- a/core/CCList.ml +++ b/core/CCList.ml @@ -160,6 +160,8 @@ let (>>=) l f = flat_map f l let (<$>) = map +let pure f = [f] + let (<*>) funs l = product (fun f x -> f x) funs l let sorted_merge ?(cmp=Pervasives.compare) l1 l2 = diff --git a/core/CCList.mli b/core/CCList.mli index 6a72b547..a94820f5 100644 --- a/core/CCList.mli +++ b/core/CCList.mli @@ -64,6 +64,8 @@ val diagonal : 'a t -> ('a * 'a) t (** All pairs of distinct positions of the list. [list_diagonal l] will return the list of [List.nth i l, List.nth j l] if [i < j]. *) +val pure : 'a -> 'a t + val (<*>) : ('a -> 'b) t -> 'a t -> 'b t val (<$>) : ('a -> 'b) -> 'a t -> 'b t