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 Responses

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.

Where Next?

Popular in Discussions Top

Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19568 166
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
IVR
Hi all, I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic. I...
New
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
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
pdgonzalez872
If this has been asked here before, please point me to where it was asked as I didn’t find it when I searched the forum. Maybe a mailing ...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

We're in Beta

About us Mission Statement