Stream: ideas

Topic: Binary operator shorthand syntax?


view this post on Zulip Brian Teague (Nov 27 2024 at 14:51):

Would it be worth adding shorthand syntax for binary operators used with pipe to convert to \n -> n ${binOp} input treating binary operators as function calls?

roundedScore = rawScore * 1000000.0
        |> Num.round
        |> Num.toF64
        |> \n -> n / 1000000.0

vs

roundedScore = rawScore
        |> * 1000000.0
        |> Num.round
        |> Num.toF64
        |> / 1000000.0

view this post on Zulip Agus Zubiaga (Nov 27 2024 at 14:56):

The static dispatch proposal would already make this nicer:

roundedScore = rawScore
    .mul(1000000.0)
    .round()
    .to_f64()
    .div(1000000.0)

view this post on Zulip Kilian Vounckx (Nov 27 2024 at 19:03):

Right now you can do

roundedScore =
    rawScore
    |> Num.mul 10000000.0
    |> Num.round
    |> Num.toF64
    |> Num.div 1000000.0

Last updated: Jun 16 2026 at 16:19 UTC