From 67757965fe7832be5752a2bcbb023660e4771ead Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Mon, 23 Aug 2010 13:58:07 +0100 Subject: [PATCH] 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 --- stdext/fun.ml | 2 ++ stdext/fun.mli | 2 ++ 2 files changed, 4 insertions(+) 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 -- 2.39.5