What are people's thoughts on using >>
as the pipe operator instead of |>
? The advantage is that it's slightly easier to type on a US keyboard (and perhaps much easier to type on keyboards where |
isn't easily reached). The disadvantage is that it eats into the "syntax weirdness budget".
But what about the right shift operator?
Does that use >> in Roc? I had (perhaps wrongly) assumed Roc would inherit Elm's Bitwise API (Bitwise.shiftLeftBy and Bitwise.shiftRightBy)
I don't think we use >>
or <<
Num.shiftLeftBy
, etc
I mean, it’s probably too uncommon. But, learned once, it shouldn’t be a problem. Maybe a single symbol since piping is frequently used operator in roc?
Once I had an idea to take tree-sitter
and run over multiple big code bases of different domains, collecting frequencies of used patterns. Maybe it can give some insights into ergonomics (btw, what do you think about the idea? Would like to know if it’s worth researching)
In the case of piping, maybe it’s used even more often than >
(but having it for piping would be hilarious). Though, bit-shifting is an even rarer operation
At least in my own code, I use the pipe operator way more often than I use the greater than operator. Despite that, I don't think making >
the pipe operator is a good idea. It would indeed be hilarious but it would also be too weird :sweat_smile:
I like the >> proposal, it makes a big difference on azerty
I also like the >> proposal for ergonomics and visuals. Similar to c++ visually.
Wouldn't being similar to c++ be a disadvantage given it would do something different than what c++ does?
I actually like the |>
operator more.
Elixir and F# are using the |>
operator - so it is probably more appealing to people from those languages.
And F# already uses the >>
operator for function composition.
And the |>
operator has nice font-ligatures <3 :
Screenshot-2023-07-25-at-08.49.56.png
I could be wrong, but I think there's a certain ""behavioral expectation"" associated with |>
in ML-like languages. I also believe a lot of roc users will have had some Elm experience, and in Elm |>
and >>
both exist ant are different.
It is, of course, a subjective opinion, but the |>
has a certain beauty to it.
On powershell, they use only |
I also like |>
more. To the people who are used to |>
, they expect pipe behavior. To the people who aren't used to |>
they are probably familiar with >>
and expect >>
to behave differently and depending on their background >>
could mean a few things.
In the editor we could detect when the user has a non-US keyboard layout and show a hint that says:
You can also type
>>
and I'll convert it to|>
for you.
when the user types |>
.
The old R syntax for a pipe is %>%
which is much more annoying to type on any keyboard. RStudio, the most popular IDE for R, has a built in shortcut ctrl+alt+m
for the pipe, which became like second nature for me when using R. I'll probably set up a shortcut in VSCode for the Roc pipe too.
R now has the classic |>
pipe syntax in base R instead of a package, so people don't use the old pipes much anymore.
Now all I can think about is how they decided that %>%
was the best option at the time :p
It’s because custom operators need to be surrounded with %
s in R, and the pipe became popular in libraries long before it was added to the language itself
Last updated: Jul 06 2025 at 12:14 UTC