baldmountain

baldmountain

Proposal: Pipe End operator |>>

Having worked a bit with Clojure’s threading operators → and ->> I find that sometimes I’d like a pipe end operator like Clojure’s ->> operator. What this would do is pass the piped value at the end of the parameter
list rather than the beginning. I’ve seen code that overcomes this shortcoming like this

data
|> &(do_something(var, &1)).()

Instead it would be nice if we could instead do:

data
|>> do_something(var)

Sorry if this has been suggested before.

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

It gets suggested every 6 months or so. Unless this brings something new to those discussions I’m probably going to suggest we lock the thread so we can avoid just having the same conversation again.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

The general answer here is to not pipe to anonymous functions at all, but create a defp named function that does the swap. This is almost always superior because names are rarely bidirectional. IE most function names don’t read as well if the order of the arguments is switched, so writing a defp gives you the opportunity to reword things properly.

CptnKirk

CptnKirk

https://github.com/taiansu/pipe_to

Supports piping to any location.

Last Post!

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Where Next?

Popular in Discussions Top

ricklove
I was just introduced to Elixir and Phoenix. I was told about the 2 million websocket test that was done 2 years ago. From my research, t...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
tmbb
This is a post to discuss the new Phoenix LiveView functionality. From Chris’s talk, it appears that they generate all HTML on the serve...
342 18595 126
New
AstonJ
If so I (and hopefully others!) might have some tips for you :slight_smile: But first, please say which area you’re finding most challen...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement