Question about BuckleScript's |. pipe operator


let foo a b = a - b;;

let r =
|. (foo b)
|. bar
r was compiled tobar(foo(a, b))`, is that an bug?


Why do you think it’s a bug?

Fast pipe puts the argument from the left to the first position, so foo(a, b) sounds about right.
Now, if you’d use a |> foo b, that would compile to foo(b, a).

Here’s a great article on fast pipe vs regular OCaml pipe:

(Or did you expect that since you’ve put parentheses around foo b, the compiler would create a partially applied version of foo?)


Thanks a lot. This is confusing when using parentheses, I think it’s better that the compiler would create a partially applied version of foo.


Well, in your particular case, you can easily use the slow pipe: a |> foo b, |> bar, since bar is unary anyway and there’s no difference between t-first and t-last.

For more complicated cases, there are pipe placeholders.

The fast pipe precedence in BuckleScript is a complicated story(1, 2), so better not rely on parentheses, I guess.


sorry for the confusion. The thing is in ast level, the paren is not distinguishable


Thanks. If I want to use parentheses, |> would be a better choice in this case. :smile: