Shower Thought: Would Parameterized Modules have changed how Elixir (and its libraries) are designed?

Here’s a bit of a geeky thought experiment: Parameterized Modules (aka “Abstract Modules”) were an experimental feature in Erlang that never left the experimental stage and were ultimately abandoned in R16.

It got me thinking—if Elixir had such a feature, could it have influenced the way libraries like Ecto, Phoenix, or Ash were implemented, particularly when it comes to component-building abstractions?

Additionally, I wonder if Parameterized Modules might have offered interesting alternatives for implementing Protocols in Elixir. Their dynamic dispatch nature seems like it could align with what parameterized modules were designed to address.

Would this feature have simplified certain patterns, or would it have introduced unnecessary complexity?

I’m curious to hear thoughts, especially from those who’ve used both Elixir and Erlang and can reflect on how parameterized modules might (or might not) fit into Elixir’s design philosophy.

1 Like

I experimented with parameterized modules when they were available. In practice, they were simpler than they might have appeared at first glance. When you ‘initialized’ a module with a constructor argument, it merely created a reference with that initial value. Subsequent function calls on that module would automatically receive this initial value as their first argument - functionally similar to how Elixir’s pipe operator (|>) works today. While you could achieve comparable functionality using Erlang parse transforms, they were (and remain) significantly more cumbersome compared to Elixir’s elegant macro system.