type Fruit
= Apple
| Banana
| Mango
fruit : Enum Fruit
fruit =
Enum.create
[ ( "Apple", Apple )
, ( "Banana", Banana )
, ( "Mango", Mango )
]
type alias Enum a =
{ toString : a -> String
, fromString : String -> Maybe a
, encode : a -> Value
, decoder : Decoder a
, list : List ( String, a )
}
Yes, saw that one too. Didnât seem to be based on the âHow to do enums in Elmâ discussion though - but not completely dissimilar.
I think I could get Enum a -> a -> Int for free by having the make function enumerate the list of values, so would not need a separate model for EnumInt.