Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
->
should just be|.
, a regular infix function with interesting printing/precedence properties as if it was a.
, and then ppx does all the real logic. Function application on the right side of fast pipe is a must if you want the regular infix behaviour. The following expressions should be all valid without requiring weird parens:The current implementation is based on the fact that it needs to be easy to stub:
let (|.) = (a, f) => f(a);
This results into the rhs of
->
not taking function application to make this work:a->f(b)
is parsed as(a->f)(b)
.The fact that there isn't function application on the rhs, has resulted into a wide range of problems with fastpipe. In printing you actually want the layout to break as if there was a function application on the rhs! The printing problems were fixed at the cost of a tremendous amount of complexity in the printer.
The following question springs to mind: are the semantics (evaluation order etc) identical when defined in user space like this, as opposed to ppx?
No, they aren't. Example:
In retrospect, not having function application on the rhs was a terrible mistake.
Fast pipe is all about function application in its current form.
If it was always done via ppx, then you wouldn't get the error in the example
above. Having
->
behave as regular infix operator with better precedence, also strokes betterwith the mental model of
|.
for function/variant piping.TODO: