travisf
I picked this pattern up from another dev and have made fairly extensive use of it with Multis:
@multi Multi.new()
...
@multi
|> Multi.put(:params, params)
|> Multi.run(:somefunc, &some_func/2
This ensures that pipechains start with a raw value and, I think, it looks a little cleaner. Does anybdy else do this? Are there any articles on this pattern? It’s fairly simple but there is some nuance due to the constraints of module attributes (I’ve only done it with Ecto.Multi.new/2 and raw values), I wonder if you would run into problems during compile time if you tried it with modules in your project. Of course you couldn’t do it with a function in the same module.
Trending in Discussions
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
This is where the projects in the Hologram Showcase get posted: apps built with Hologram and libraries made for it. New ones go up usuall...
New
Hi everyone!
This is our fourth edition. Last year, 1,000+ developers took part. The more of you who answer, the more useful the results...
New
I’ve been fixing race condition / crash bugs in an open source org, for a few months now and almost all of them had the same problem. The...
New
Over the years I’ve tried dozens of time tracking and invoicing apps, and Harvest was the only one I liked. Primarily due to its relative...
New
Hi everyone,
I asked Claude (Anthropic’s AI) a question: if AI writes most of the code, what should a language on the BEAM look like? It...
New
I have a project that I’d like to build in Elixir, but there’s a statistical decision engine component that will likely use hierarchical ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hi everyone :waving_hand:
I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #ai
- #authentication
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-eu
- #distillery
- #security
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
andyleclair
How does it ensure the pipe chain starts with a raw value?
IMO I would not do this. We have some legacy tests that use module attrs and they are a bit of a PITA to deal with and refactor.
If you want your pipe chains to start with a raw value, maybe use credo?
sodapopcan
Not to pile on but I’m really not a fan of things like this. This is really no different than a single-line private function that I have to jump to to be sure of what it is. It’s also creating a compile-time dependency on
Ecto.Multiwhich isn’t a huge deal in this case but not ideal. I agree with @andyleclair that credo is the best tool for the particular outcome you’re looking for.dimitarvp
This is a complete no-go, module attributes basically get replaced with their value at compile time which also means that you might get 2 different
Multi.newvalues (though I have not tested this so it’s likely not true).But as the others said there’s zero value in this.
Multi.newis not an expensive operation either so your reason to try to do this is quite puzzling. What’s your rationale? “Looks little cleaner” is, I am sure we all agree, a very subjective statement, and even if we agree that it’s kinda sorta objective there are still degrees; you are gaining next to nothing by doing this replacement with a module attribute.andyleclair
I have seen this attitude before in people who are just learning elixir, fussing over micro things that map to things they know from other languages.
My advice is: don’t worry about it! Write the most straightforward, obvious code you can, and go back to make it faster later if you need to. Always heed the words of Saint Joe:
“Make it work, then make it beautiful, then if you really, really have to, make it fast. 90 percent of the time, if you make it beautiful, it will already be fast. So really, just make it beautiful!”
acangiano
I tend to use module attributes as storage for compile-time constants, which is particularly handy for “caching” expensive operations with no runtime dependencies. I don’t think that what you’re doing is particularly bad but it feels unnecessary.
travisf
From the responses; I will stop doing it. The one thing I’m a little confused about is when you say “If you want your pipe chains to start with a raw value, maybe use credo?” I’m not sure exactly what you mean?
I actually got into this habit because of credo, although I can see that it’s now off by default but I think at one time the codebase I was throwing PiepChainStart warnings.
al2o3cr
I’d be surprised if starting a chain with
Multi.new()triggers that Credo check - there is specific code to allow that shape when there are no args:https://github.com/rrrene/credo/blob/v1.7.5/lib/credo/check/refactor/pipe_chain_start.ex#L205-L211
dimitarvp
As a guy working with Elixir for 8 years now, I am confused as well.
sodapopcan
I was confused by “make sure it starts with a raw value” and how this pattern would solve it. I probably should have just asked but instead I ass-u-me’d you meant to ensure you use
Ecto.Multi.new()over%Ecto.Multi{}. Credo in this case could just make sure that the latter isn’t used anywhere other than on the left hand side of a pattern match (or guard, I suppose).andyleclair
Sorry, what I meant was “use a credo rule to enforce this”