tmbb

tmbb

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?

Most Liked

LostKobrakai

LostKobrakai

Given Explorer doesn’t implement the protocol I’d argue you shouldn’t do so either. There’s a warning about to_enum being an expensive operation, so hiding it being called is imo not a great idea.

My take would be just expecting an enumerable and letting users call Series.to_enum on their own. It’s not like that additional function would make using your library more difficult and the explicitness of the call being present in users code is imo justified due to the importance for performance.

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
maennchen
:warning: Security advisory: Decimal DoS vulnerability A vulnerability has been published for decimal where very large exponents can cau...
New

Other Trending Topics Top

CodeSync
What if you could build production-ready RAG entirely in Elixir? George Guimarães, ElixirConfEU 2026 https://www.youtube.com/watch?v=tNB...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews