I'll start off by saying that I think this isn't possible yet based on my understanding that Gleam doesn't have reflection. However, I've been doing the Exercism track and in the "Resistor Color" problem, it asks you to make a list to return all of the color variants. It would be cool if there was a way to do this with some kind of built in function. Does such a function exist?
#List of all variants of a type?
1 messages · Page 1 of 1 (latest)
It does not, no
Not sure what this would do since this behaviour kind of breaks down when you have variants that are not just atoms under the hood
For example if you had Grey(opacity: Int) would the function return Grey or something like Grey(0), note the former is actually fn(Int)-> Colour but the latter doesn’t exactly make any sense as a return value