Stream: ideas

Topic: piping the function argument


view this post on Zulip Oskar Hahn (Dec 03 2023 at 11:05):

I like the possibility, to pipe values between functions. In a lot of cases, I have a function, that takes one argument and pipes it into a stream of functions

myFunc : \arg ->
  arg
  |> doSomething
  |> doSomethingElse
  |> doMore

What is a bit strange is, that I have to write the argument two times. One time as argument, and one time at the beginning of the piping.

In elm, I had the possibility, to pipe the argument to the first function without writing it :

myFunc =
  doSomething
  >> doSomethingElse
  >> doMore

I don't like the elm style, since it is hard to see, that the function takes an argument. I have to write the argument two times or zero times.

It would be nice, if I could write the argument only once.

Would the following be possible?

myFunc : \arg ->
  |> doSomething
  |> doSomethingElse

If a function has only one argument and the function starts with |>, then the argument is piped into the first function.

Would it be possible to implement this kind of syntax sugar?

view this post on Zulip Declan Joseph Maguire (Dec 03 2023 at 13:10):

I'd literally been thinking about this earlier today. Didn't post it because I felt I'd already done enough bikeshedding elsewhere about minor matters of syntax regarding pipelines and lambdas

view this post on Zulip LoipesMas (Dec 03 2023 at 14:02):

I think this falls in the same category as pointfree function composition (although the order of operations is inversed), so I guess the same downsides apply? I.e., conciseness vs readability/intuitiveness


Last updated: Jun 16 2026 at 16:19 UTC