I have this function:
“genre” is always a string, but in can only take 3 different values. How do I type it in Elixir ?
I’m thinking on something like enum types in C++:
@type valid_genres :: "horror" | "action" | "drama"
@spec def top(genre:: valid_genres)
I would use atoms instead of strings and then have a conversion to and from the string representation.
@type valid_genres :: :horror | :action | :drama
I don’t think there is any simple way to type on different values of strings (that I am aware of).
There isn’t. Strings can’t be typed beyond