Is it possible to generate a list from a datatype's possible values in Haskell?
haskell, list-comprehension, types
Solution
Yes it can. It's a duty of Enum and Bounded type classes e.g.
λ data Shape = Circle | Rectangle | Triangle | Pentagon deriving (Show, Enum, Bounded)
λ [minBound .. maxBound] :: [Shape]
[Circle,Rectangle,Triangle,Pentagon]
λ [minBound ..] :: [Shape]
[Circle,Rectangle,Triangle,Pentagon]
Problem
Can a list be generated from a type's possible values? E.g. `data Shape = Circle | Rectangle | Triangle | Pentagon` to `[Circle,Rectangle,Triangle,Pentagon]`