News for hackers. Stuff that matters.
Re:Pipe Operator (|>) For JavaScript by sph on Friday January 20, 2023 @11:36AM (#34455574)
As I mentioned upthread, most Elixir functions are designed to have the thing they operate on as first argument.

    computation() |> &(Map.put(my_map, key, &1))
is terrible style when

    Map.put(my_map, key, computation())
works just as well and is more readable. It is pretty rare to have a pipeline that needs to insert the value elsewhere than the first position. And please, do not write single element pipelines, I see them far too often from Elixir beginners.
Re:Pipe Operator (|>) For JavaScript by ollien on Friday January 20, 2023 @12:51PM (#34456871)
I agree! I even pointed this out in my comment, but perhaps not clearly :)

I think that the way it's done is a net-positive in designing cleaner APIs, but there are times when I've already done a pipeline, and storing the output is just the last step. This last step is just frustratingly, not always possible. I don't think one should do something like the above, it's just what you must resort to if you _did_ want to do it.

Re:Pipe Operator (|>) For JavaScript by sph on Friday January 20, 2023 @01:55PM (#34457911)
There is nothing wrong with doing

   data =
     this
     |> is
     |> a
     |> pipeline

   save_to_file(file, data)
Instead of trying to put the call to save_to_file into the pipeline by wrapping it in a closure.