I’m working on a data plotting library for Elixir. I don’t want to force people to use Explorer if they don’t want to, especially because for the actual visualization I have to build normal Elixir structures which represent the state and the geometric figures I want to draw. This means I want to accept sometning like plot([1,2,3], [1,2,3])
.
However, I’d like to make it very easy to use series as data sources, and the easiest way of being able to use both series and lists is to implement the Enum
protocol for series (basically by calling the already existing Series.to_enum/1
function.
Is this ok? This is my first time implementing a protocol for a non-trivial structure not written by me, and because protocol implementations are global, I wonder if that would be a problem. Should I wrap it in something custom such as %DataSource{}
and then implement the %DataSource{}
protocol for lists, streams and whatever makes sense?