Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005236OCamlOCaml generalpublic2011-03-07 23:202013-08-31 12:44
Reportertill 
Assigned Toxclerc 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.12.0 
Target VersionFixed in Version3.12.1+dev 
Summary0005236: Add %revapply as a primitive (for infix pipe)
DescriptionOne 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.
TagsNo tags attached.
Attached Filespatch file icon revapply.patch [^] (2,219 bytes) 2011-03-07 23:20 [Show Content]

- Relationships

-  Notes
(0005840)
dbuenzli (reporter)
2011-03-08 01:00

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.
(0005868)
thelema (reporter)
2011-04-17 21:06

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?
(0006740)
lefessan (developer)
2012-01-19 22:06

I modified the fix (SVN commit r12055 in version/3.12):
- it should now print correctly the location
- non-unary functions are also optimized (before, they would be partially applied twice).
(0006744)
hcarty (reporter)
2012-01-19 22:53

Will this be included in trunk/3.13 as well?

- Issue History
Date Modified Username Field Change
2011-03-07 23:20 till New Issue
2011-03-07 23:20 till File Added: revapply.patch
2011-03-08 01:00 dbuenzli Note Added: 0005840
2011-04-17 21:06 thelema Note Added: 0005868
2011-04-29 16:25 doligez Status new => acknowledged
2011-09-15 15:24 xclerc Status acknowledged => resolved
2011-09-15 15:24 xclerc Fixed in Version => 3.12.1+dev
2011-09-15 15:24 xclerc Resolution open => fixed
2011-09-15 15:24 xclerc Assigned To => xclerc
2012-01-19 22:06 lefessan Note Added: 0006740
2012-01-19 22:53 hcarty Note Added: 0006744
2013-08-31 12:44 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker