toEnum problem
Michael Ackerman
ack@nethere.com
Fri, 29 Jun 2001 00:42:25 -0700
Hello,
I tried this:
data Nat = Zero | Succ Nat
instance Enum Nat where
fromEnum Zero = 0
fromEnum (Succ n) = 1 + fromEnum n
toEnum 0 = Zero
toEnum n = if n > 0 then 1 + toEnum n
else error "bah"
and I get, from Hugs, the error message,
Implementation of toEnum requires extra context
Expected type: Enum Nat => Int -> Nat
Missing context: (Num Nat, Num Nat)
I'm baffled (esp. by the last line). Any help will be appreciated.
Michael Ackerman