Daily Shaarli

All links of one day in a single page.

February 7, 2024

ElixirNitpicks

Nice write up. Aside from these mentioned, I also wanted to point out a few problems about Protocols.

  1. the implementation on struct is fine, but implementations on primitive types are very different and sometimes awkward
  2. the first argument is forced to be the type that implements the protocol, making it difficult to define abstract methods on, for example, a set of values
  3. there is no concept of associated type, associated constant,
  4. the role of protocols mostly overlaps with a @behaviour but a behaviour is more flexible

And here are more places I'd like to see improvements (some pointed out in the article, too):

  • the lack of simpler struct construction/deconstruction syntax sugar, forcing everyone to write code like %{a_long_property: a_long_property} repeatedly
  • the lack of early return. the design of with discards the information about the mismatching branch.
  • Ecto.Multi is not composable (I tried to fix it via https://github.com/shouya/ecto-tx)