An enumeration type contains only nullary constructors, so its finite set of values can be traversed and mapped to numeric positions. Deriving Enum supplies that behavior automatically. section 15.3.3
Use Enum to work with constructor order and ranges:
- Derive Bounded as well to obtain minBound and maxBound for the complete range. section 15.3.3
Enumerating file types
data FileType = Other | Image | Compressed deriving (Show, Read, Eq, Enum, Bounded) allFileTypes :: [FileType] allFileTypes = enumFromTo minBound maxBound The helper returns [Other, Image, Compressed] without manually repeating the first and last constructors.






















