[Haskell-cafe] Enum instantiation

R J rj248842 at hotmail.com
Fri May 21 21:13:34 EDT 2010


I'd like to make "Day" an instance of class "Enum," but the definition of toEnum below seems to be completely wrong, because integers seem not permit pattern matching.  How is toEnum defined?  Thanks.
data Day                   =  Sunday                           |  Monday                           |  Tuesday                           |  Wednesday                           |  Thursday                           |  Friday                           |  Saturday                           deriving (Eq, Ord, Show)
instance Enum Day where    fromEnum Sunday        =  0    fromEnum Monday        =  1    fromEnum Tuesday       =  2    fromEnum Wednesday     =  3    fromEnum Thursday      =  4    fromEnum Friday        =  5    fromEnum Saturday      =  6        toEnum 0               =  Sunday    toEnum 1               =  Monday    toEnum 2               =  Tuesday    toEnum 3               =  Wednesday    toEnum 4               =  Thursday    toEnum 5               =  Friday    toEnum 6               =  Saturday 		 	   		  
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100521/2044a82f/attachment.html


More information about the Haskell-Cafe mailing list