JKWA
Author of Advanced Functional Programming with Elixir
There are many ways to solve equality: duck typing, injection, protocol dispatch.
Here’s why Funx uses the one it does:
Trending in Blog Posts
TL;DR: Give https://cure-lang.org a try—perhaps you will like it.
New
I finally found time to write down my journey away from ExMachina, including the workaround I tried first and the API experiments that fo...
New
An automated trigger fired every two minutes for 8 hours. 243 agent runs. 31M tokens. $63 wasted. The problem: nobody noticed until morni...
New
The words are insufficient to describe what transpired. What we tried to do met what the people wanted it to be. It became beautiful.
Th...
New
Hi everyone,
I’ve been building BetterTyping (https://bettertyping.org) on and off since 2021. It’s a free typing game: practice alone, ...
New
Turns out a 1ms network hiccup is enough to silently lose broadcasts for a node and that node is just quietly wrong forever
Wrote it up ...
New
If you’ve found an interesting or cool Elixir related blog post and think it’s worth sharing please add it to this thread :icon_biggrin: ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
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
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
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
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
lucas-stellet
Hey @JKWA,
First of all, thanks for your book.
I bought it recently and it’s been an enjoyable journey reading it.
I read your article and ran the LiveBook, and I liked your idea so much that I decided to create my own version of your implementation.
The main difference is that I created a separate module for the
Protocoland useddefdelegateto route the function depending on the arity.I would like to your opinion about it.
Thanks!
JKWA
Sure, here’s my take.
From a functional point of view, I think of the protocol as the abstraction itself, defining what it means to be equal. I use
Eq.Utilsas a convenient place to keep helper functions that work withEq.I had considered naming
EqasEq.Protocol, but in the end I leaned away from that. I felt that framing treated the protocol more like an interface for modules to implement, which doesn’t quite match how I think about the abstraction.The combination of
defdelegate eq?(a, b), to: Eq.Protocolandeq?(a, b, comparator)is behaviorally equivalent to my approach, but to me it reads a bit like OOP. Nothing wrong with that, just a different frame.But those are really just semantics, the real difference is in how we handle the third argument. You’re passing a function, while I’m passing a map with an
:eq?key that holds the function. Treating the comparison logic as data makes it easier to compose later. For instance, check out the Funx monoid.JKWA
You might find AI Tutor for Functional Programming - Funx , interesting. Feed in your example and get Claude to focus on the different
eq?/3functions. If it is attending to the usage rules, it does a pretty good job of explaining why you might choose one over the other.