Stream: beginners

Topic: Replace |> with >>


view this post on Zulip Martin Stewart (Jul 23 2023 at 16:27):

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".

view this post on Zulip Kiryl Dziamura (Jul 23 2023 at 16:53):

But what about the right shift operator?

view this post on Zulip Martin Stewart (Jul 23 2023 at 16:58):

Does that use >> in Roc? I had (perhaps wrongly) assumed Roc would inherit Elm's Bitwise API (Bitwise.shiftLeftBy and Bitwise.shiftRightBy)

view this post on Zulip Brendan Hansknecht (Jul 23 2023 at 17:07):

I don't think we use >> or <<

view this post on Zulip Brendan Hansknecht (Jul 23 2023 at 17:08):

Num.shiftLeftBy, etc

view this post on Zulip Kiryl Dziamura (Jul 23 2023 at 19:53):

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

view this post on Zulip Martin Stewart (Jul 23 2023 at 19:57):

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:

view this post on Zulip Anton (Jul 24 2023 at 09:48):

I like the >> proposal, it makes a big difference on azerty

view this post on Zulip Paul M (Jul 24 2023 at 22:35):

I also like the >> proposal for ergonomics and visuals. Similar to c++ visually.

view this post on Zulip Brendan Hansknecht (Jul 24 2023 at 22:38):

Wouldn't being similar to c++ be a disadvantage given it would do something different than what c++ does?

view this post on Zulip Artur Domurad (Jul 25 2023 at 06:54):

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

view this post on Zulip Fábio Beirão (Jul 25 2023 at 07:43):

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 |

view this post on Zulip Jacob (Jul 25 2023 at 14:20):

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.

view this post on Zulip Anton (Jul 25 2023 at 14:26):

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 |>.

view this post on Zulip Hannes (Jul 25 2023 at 14:35):

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.

view this post on Zulip Anton (Jul 25 2023 at 14:50):

Now all I can think about is how they decided that %>% was the best option at the time :p

view this post on Zulip Ajai Nelson (Jul 25 2023 at 15:35):

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