From: Jonathan Knowles Date: Mon, 23 Aug 2010 12:58:07 +0000 (+0100) Subject: Adds a forward pipe operator to the higher-order function library. The forward pipe... X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=67757965fe7832be5752a2bcbb023660e4771ead;p=xcp%2Fxen-api-libs.git Adds a forward pipe operator to the higher-order function library. The forward pipe operator facilitates left-to-right function composition. Signed-off-by: Jonathan Knowles --- diff --git a/stdext/fun.ml b/stdext/fun.ml index a8be363..4088cac 100644 --- a/stdext/fun.ml +++ b/stdext/fun.ml @@ -17,4 +17,6 @@ let (++) f g x = comp f g x let comp2 f g a b = f (g a b) let (+++) f g a b = comp2 f g a b +let (|>) a f = f a + let ($) f a = f a diff --git a/stdext/fun.mli b/stdext/fun.mli index 66cc846..e563ed0 100644 --- a/stdext/fun.mli +++ b/stdext/fun.mli @@ -7,4 +7,6 @@ val comp : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c) val comp2 : ('b -> 'c) -> ('a1 -> 'a2 -> 'b) -> ('a1 -> 'a2 -> 'c) val (+++) : ('c -> 'd) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'd val (++) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c +(** Forward pipe operator: facilitates left-to-right function composition. *) +val (|>) : 'a -> ('a -> 'b) -> 'b val ($) : ('a -> 'b) -> 'a -> 'b