From 2a21181580a9b212afd62f3c3c7158ced0bc6707 Mon Sep 17 00:00:00 2001 From: Nicola Mometto Date: Thu, 11 Apr 2024 14:51:55 +0100 Subject: [PATCH] feat(CCFun): add (||>) --- src/core/CCFun.ml | 1 + src/core/CCFun.mli | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/core/CCFun.ml b/src/core/CCFun.ml index 242032a5..b407d6a5 100644 --- a/src/core/CCFun.ml +++ b/src/core/CCFun.ml @@ -64,6 +64,7 @@ module Infix = struct let ( %> ) = compose let[@inline] ( % ) f g x = f (g x) let ( let@ ) = ( @@ ) + let ( ||> ) (a, b) f = f a b end include Infix diff --git a/src/core/CCFun.mli b/src/core/CCFun.mli index 5476b580..0536a734 100644 --- a/src/core/CCFun.mli +++ b/src/core/CCFun.mli @@ -81,6 +81,9 @@ module Infix : sig (** [let@ x = foo in bar] is the equivalent of [foo @@ fun x -> bar]. It can be very useful for resource management, alongside with {!protect}. @since 3.11 *) + + val ( ||> ) : 'a * 'b -> ('a -> 'b -> 'c) -> 'c + (** [x ||> f] is [f (fst x) (snd x)] *) end include module type of Infix