as of April, 2020
After reading this, https://www.javierchavarri.com/data-first-and-data-last-a-comparison/,
I thought I should use ->
over |>
for a performance reason.
by the way, the post was an excellent article 👍🏼
->
: pipe first, more on here, https://reasonml.github.io/docs/en/pipe-first|>
: pipe last, for this you can read the first link above.
You can see the experiment here.
The result looks same to me 🤷🏻♂️
but to be fair, it's a quite simple example, so I'm not sure how this will work with more complex examples
Anyway I'm guessing the compiler must have improved some optimizations on this over time.
Although you can mix them together, you might run into some issues, when you do in one chunk. An example is here
if you want to stick with
List
instead ofBelt.List
when you want to use->
over|>
// this is
[0, 1] -> List.map(x => x + 1, _);
// basically doing the "same" thing as below:
[0, 1] |> List.map(x => x + 1);
about using
->
andf(..., _)
together, it's thanks to pipe placeholders
- formatting reasons
// I prefer this
a |> b |> c;
// over this
a->b->c;
- Play nicer with standard module like
List
- There seems to be no cost on JS side. (correct me if I'm wrong on this)
I think I will use ->
too in cases where it makes more sense to use over |>
.