[Haskell-cafe] Declaring a tuple of instances of Enums as an instance of the Enum class

R J rj248842 at hotmail.com
Sun May 23 09:18:17 EDT 2010


Say I've got a type "Month" declared as an instance of the "Enum" class, and a type "MonthPair" declared as a pair of months:
data Month                 =  January                           |  February                           |  March                           |  April                           |  May                           |  June                           |  July                           |  August                           |  September                           |  October                           |  November                           |  December                           deriving (Eq, Enum, Ord, Show)
type MonthPair             =  (Month, Month)                           deriving (Enum)
The "deriving" on "MonthPair" gives me the error "parse error on input 'deriving'".
Why is this error generated?  Is there a syntax error, or is there a conceptual problem with enumerating a Cartesian product, such as Month x Month?  The cardinality of the Cartesian product is finite (including the bottom values, cardinality = 1 + (12 + 1)*(12 + 1) = 170), and so the product is amenable at least to some arbitrary enumeration (such as Cantor's diagonal method).
Thanks. 

 		 	   		  
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100523/37ed47c4/attachment.html


More information about the Haskell-Cafe mailing list