Empty enumeration [GHC-10190]
This warning, controlled by the
-Wempty-enumerations flag, is emitted when an enumeration is empty. This can occur when the beginning of the enumeration is greater than the end, for instance.
An enumeration where the lower bound is greater than the upper bound
Main.hs:5:14: warning: [-Wempty-enumerations] [GHC-10190] Enumeration is empty | 5 | let enum = [5 .. 1] | ^^^^^^^^
5 is greater than
1, so the resulting list would be empty. This probably indicates a bug, because the most straightforward way to write the empty list is
. One solution to this is to provide the second step in the enumeration so that the code will count down rather than up.
module Main where main :: IO () main = do let enum = [5 .. 1] print enum
module Main where main :: IO () main = do let enum = [5, 4 .. 1] print enum