From ed3bf4ba267d9e7756faf93b886b7ba2ff549efc Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 6 Nov 2014 16:08:36 +0100 Subject: [PATCH] CCList.(>|=) infix map --- core/CCList.ml | 4 +++- core/CCList.mli | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/CCList.ml b/core/CCList.ml index cddb1911..03713d62 100644 --- a/core/CCList.ml +++ b/core/CCList.ml @@ -51,6 +51,8 @@ let map f l = List.rev (List.rev_map f l) = map f l) *) +let (>|=) l f = map f l + let append l1 l2 = let rec direct i l1 l2 = match l1 with | [] -> l2 @@ -550,7 +552,7 @@ module type MONAD = sig end module Traverse(M : MONAD) = struct - open M + open! M let map_m f l = let rec aux f acc l = match l with diff --git a/core/CCList.mli b/core/CCList.mli index 65356855..939888c4 100644 --- a/core/CCList.mli +++ b/core/CCList.mli @@ -33,6 +33,10 @@ val empty : 'a t val map : ('a -> 'b) -> 'a t -> 'b t (** Safe version of map *) +val (>|=) : 'a t -> ('a -> 'b) -> 'b t +(** Infix version of [map] with reversed arguments + @since NEXT_RELEASE *) + val append : 'a t -> 'a t -> 'a t (** Safe version of append *)