New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add %revapply as a primitive (for infix pipe) #5236
Comments
Comment author: @dbuenzli I also use this in various places in my code (it often shows up in combinator approaches). Can't comment on the performance hit though. |
Comment author: thelema This solution, while workable, doesn't seem like the right way to do this. What about improving the inliner to inline function composition/application structures (like this and (fun f g x -> g (f x)), etc) in general? |
Comment author: @lefessan I modified the fix (SVN commit r12055 in version/3.12):
|
Comment author: @hcarty Will this be included in trunk/3.13 as well? |
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
Original bug ID: 5236
Reporter: till
Assigned to: @xclerc
Status: closed (set by @xavierleroy on 2013-08-31T10:44:28Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.12.0
Fixed in version: 3.12.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: bitbckt "Dmitry Grebeniuk" dario @ygrek bobot thelema @hcarty @dbuenzli yminsky @oandrieu
Bug description
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.
File attachments
The text was updated successfully, but these errors were encountered: