Merge pull request #450 from Bronsa/nicola/tup_pipe

feat(CCFun): add (||>)
This commit is contained in:
Simon Cruanes 2024-04-11 10:25:47 -04:00 committed by GitHub
commit 570e3f8d67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -64,6 +64,8 @@ module Infix = struct
let ( %> ) = compose
let[@inline] ( % ) f g x = f (g x)
let ( let@ ) = ( @@ )
let ( ||> ) (a, b) f = f a b
let ( |||> ) (a, b, c) f = f a b c
end
include Infix

View file

@ -81,6 +81,14 @@ 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)]
@since NEXT_RELEASE *)
val ( |||> ) : 'a * 'b * 'c -> ('a -> 'b -> 'c -> 'd) -> 'd
(** like [||>] but for tuples of size 3
@since NEXT_RELEASE *)
end
include module type of Infix