Approach to auto-implement protocols for datastructure that implements other protocol?

I am looking at a couple of my old libraries again, and want to give them some new love.

Specifically, the arrays library is functionally complete, but missing some quality-of-life things that prevented me from releasing it as 1.0 in the past.

Currently, the library consists of:

  • The Arrays.Protocol protocol, which should be implemented for every kind of array.
  • The Arrays module that dispatches to the former when required.
  • A couple of built implementations (one wrapping :erlang.array and one wrapping Elixir maps).

Now when someone implements the Arrays.Protocol protocol, it is possible to define trivial implementations for the Inspect/Enumerable/Collectable/Insertable/Extractable (see here).

How should a library like this empower people creating other implementations to autogenerate these implementations for their datastructures too?

2 Likes