Apemb
Hello all,
I have been using Elixir for a bit of time, and each time I wrote code like this I wondered if there were not a better way than chain with functions.
So I created Chain GitHub - Apemb/chain: An Elixir library that mimics the JavaScript Promise API, but only as a synchronous way to organise code. · GitHub
What do you think ?
Do you see it as useful ?
Trending in Announcing
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
I released Doggo, a collection of unstyled Phoenix components.
https://github.com/woylie/doggo
Features
Unstyled Phoenix components....
New
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
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi everyone,
I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
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
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
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
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kokolegorille
Hello and bienvenue…
You don’t like to use with?
There is also witchcraft, which might have a similar purpose.
Apemb
I find it a bit unclear when there are a lot of “errorable” functions. (like for a use case)
Some example of usage from my current projet :
It would be a bit less clear with with I find.
I will check out witchcraft for sure.
NobbZ
Additionally to @kokolegorille s list:
ok_joseauto_pipekokolegorille
With witchcraft, it would look like this…
But there are more operators… GitHub - witchcrafters/witchcraft: Monads and other dark magic for Elixir · GitHub
kokolegorille
There is also ok library, by @Crowdhailer
Apemb
Thank you for all the links
I have quite a bit to read on. Especially witchcarft, (even if it does seem a tad too complex to me. My team and I are no Haskell FP wizards, at least not yet).
We were quite used to the Javascript promise syntax, so the Chain API is inspired by the standard JS Promise. And is not a macro, more like the Ecto Multi Struct, that manages a transaction. So you have more freedom with were and what you do with you Chain Struct.
I will check on to see if those libs have the features we use :
We have sort of complicated use cases, and Chain helps managing the complexity. (Like this one)
Chain misses a Promise.all equivalent, or anyway to manage Enumerable that have to be mapped to something else.
ondrej-tucek
Maybe I’m wrong, but isn’t the catching thrown error anti-pattern?:
Also you can use the result library, for example this a way.
Apemb
Yes, I suppose it is an anti-pattern.
Our need was to be able to verify that a cron job had run. As Ecto can throw in some circumstances (as far as I understand at least) having that possibility was really helpful to ensure we log any error that can happen in our job and transfer that log to sentry.
Chain gives you the stack trace with the thrown error, so in our case the error is re-thrown with the initial stack trace after we log it.
Result seems a great library, it seems simple enough and might cover much of our usecase. I will check it out, thank you.
ondrej-tucek
I get it. We solved something similar I think. We have a lot of measured data from sensors at Postgres. First we came with cron job for aggregating. After that we refactored cron job to GenServer similar to José Valim’s answer + used
Loggerfor logging errors. In the end we rewrote it with Ecto Query