[Haskell-cafe] Enum instantiation

2010-05-21 Thread R J
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

Re: [Haskell-cafe] Enum instantiation

2010-05-21 Thread Antoine Latter
2010/5/21 R J rj248...@hotmail.com: 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. Hi, What error are you getting when you try your class

Re: [Haskell-cafe] Enum instantiation

2010-05-21 Thread Gregory Collins
R J rj248...@hotmail.com writes: 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. You could try using guards: toEnum x | x == 0= Sunday

Re: [Haskell-cafe] Enum instantiation

2010-05-21 Thread Antoine Latter
On Fri, May 21, 2010 at 8:59 PM, R J rj248...@hotmail.com wrote: If I type toEnum 5, the error I get is: interactive:1:0:     Ambiguous type variable `a' in the constraint:       `Enum a' arising from a use of `toEnum' at interactive:1:0-7     Probable fix: add a type signature that fixes