Add %revapply as a primitive (for infix pipe) #5236
Original bug ID: 5236
One emerging idiom (at least in jane street's code base) is to define a pipe operator to string computations as such:
let (|>) x f = f x
This, sadly, does come with a performance hit (enough that we've actually seriously considered ). The attached patch introduces a new primitive (%revapply) that can be used to define |>:
external (|>) : 'a -> ('a -> 'b) -> 'b = "%revapply"
Feedback and comments would be greatly appreciated.
The text was updated successfully, but these errors were encountered:
Previous fix would introduce applications without correct locations. Also, non-unary functions would not be correctly optimized (this is fixed in Simplif.simplify_exits). Added one test in the testsuite. git-svn-id: http://caml.inria.fr/svn/ocaml/version/3.12@12055 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02