so today, this does not compile:
Str.toUtf8 "Hi there!" |> Str.fromUtf8 == Ok "Hi there!"
the reason is the precedence of |> and ==
Screen-Shot-2023-03-29-at-9.15.30-AM.png
to get this to work, we have to put parens around the part before ==
Screen-Shot-2023-03-29-at-9.15.58-AM.png
I can't think of a use case where this is the behavior we want
What about?
positions
|> List.keepIf \pos -> pos.x == 0
|> something
hm, I'd assume in that case the == would be inside the lambda :thinking:
I'll give it a try!
Ah ok. Yeah, I can't think of anything else
yeah that still works
(if I change the precedence such that the original example works)
For cases where I'd use == to construct a bool to pass as an argument to the piped function, I'd use parens anyway
Like in builder pattern:
Button.new
|> Button.disabledIf (count == 0)
|> Button.view
yeah I think the current way, if you use |> and == you always get a type mismatch :sweat_smile:
because you'll always either be trying to give too many arguments to == or else you'll be trying to run a Bool as a function
Cool! I like this
Would this extend to all comparison operators?
I might be missing something, but I think this would work for all infix operators
yeah I think |> should probably just have the highest precedence :thinking:
Except for unary operators, right? I think -a |> b should mean (-a) |> b and not -(a |> b)
That might always be the case when mixing unary and infix. Not sure how the parser works.
oh sure
yeah I'm just talking about infix operators here
Cool cool
Crazy question. With the change in precedence, would this work:
a
|> SomeTransform
|> == SomeResult
Note, ==could theoretically be any other infix operator.
The fact that the |> parts are on multiple lines, and the == is on the same line, make that read really strangly to me
If we want to reduce the precedence, IMO that really only makes sense if we start formatting it differently
Right now, if you have a '+' operator somewhere in the middle of a pizza chain (with no parens), you'll get an error that one of the elements of that chain is not a function call (I think / assume?). If we just naively reduce the precedence, that + operator will be at the root of the tree - which will IMO be very unintuitive with the normal formatting
yeah I don't think |> == ought to work :big_smile:
in genearal I don't think we should allow multiple infix operators in a row
x < y < z can be pretty nice in some languages (as an equivalence for x < y && y < z), but it admittedly doesn't come up very often, and there are usually additional rules to prevent someone from writing out-of-order expressions like x > y < z
Last updated: Jun 16 2026 at 16:19 UTC