[Haskell-cafe] Printing list of enum type

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


Michael,

> 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.

Regards,
John

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]
[Red,Blue,Green,Yellow,Orange,Brown,White,Black]



More information about the Haskell-Cafe mailing list