pertsevds
Hey folks,
I made a tiny macro that lets you assign a piped value to a variable without breaking the flow. For example:
data
|> transform()
|> process()
|> finalize()
|> assign_to(result) # Assign to result variable
or even during the pipeline:
data
|> transform()
|> assign_to(step1) # Capture without breaking flow
|> process()
|> assign_to(step2)
|> finalize()
|> assign_to(result) # Assign to result variable
Sure, it’s not idiomatic — but we’ve got then/1, tap/1, even throw/1, so I got curious about what assign from pipe could look like.
Had to jump through a few hoops to avoid compiler warnings, but it works smoothly now.
Docs: pipe_assign v1.1.2 — Documentation
Hex.pm: pipe_assign | Hex
Repo:
Trending in Announcing
Hey everyone!
Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application.
This library uses Erlang esaml to provide
plug enabl...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi all!
I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas.
You...
New
Hello
Published a new library - ProcessHub!
ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
This showed up on my feed.. anyone heard of it? Just hype?
Ox Alpha is a reasoning model designed for coding, sustained ag...
New
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
It’s not that it’s vocabulary is too advanced. It’s something worse.
I get lost trying to follow even a paragraph written by Claude. It’...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
DaAnalyst
Bookmarked for the very next time I need it
Thanks!
tomg
You could achieve the same result and readability by using the with clause in my opinion:
pertsevds
Yes. But I love pipes
sodapopcan
Pipe-ists gonna pipe
byu
I look forward to trying this out.
How would you compare and contrast this library’s aims and functionality with the ok library?
pertsevds
okis a syntactically shorterwithandthenalternative. It’s not suitable to assign to variable in pipe flow.pipe_assignis an alternative for an equal sign but not before pipe flow, but after. It’s suitable to assign to variable in pipe flow.derek-zhou
I wonder what compile warnings you were referring to. The last time I checked, this works:
pertsevds
derek-zhou
If you are not going to use the old
resultwhy initialize it? If you are not going to use the newresultwhy bind to it? IMHO this warning is useful.pertsevds
Now when I think about it… you’re right! =)
I’ll change the behavior.
Thank you.