A range is Haskell’s compact list notation for enumerating values between bounds, or continuing from a starting value. Write [start .. end] for consecutive values, or [start, next .. end] to specify a step. section 2.3.1 section 15.3.3
Use ranges with numeric values and characters:
- An omitted end creates an open-ended range, as in [1 ..], while a specified end limits the result. section 15.3.3
Enumerating a custom type
Ranges also work with enumeration types. A type such as data EnumType = A | B | C deriving (Show, Enum) supports [A .. C], which produces [A,B,C]. The notation corresponds to enumFromTo; deriving Bounded additionally allows enumFromTo minBound maxBound to enumerate every constructor without naming the endpoints.







