[Haskell-cafe] Printing list of enum type

John Dorsey haskell at colquitt.org
Tue Apr 14 15:33:00 EDT 2009


> What do I need to add to this Color enum type to print a list of them?

You can also easily print a list of /all/ of them.


scratch$ cat color.hs 

data Color
    = Red
    | Blue
    | Green
    | Yellow
    | Orange
    | Brown
    | White
    | Black
  deriving (Show,Enum,Bounded)

scratch$ ghci color.hs 
*Main> [minBound..maxBound] :: [Color]

More information about the Haskell-Cafe mailing list