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, th
Oops. Sorry for stupid question.
Michael Ackerman
Levent Erkok wrote:
>
> On Friday 29 June 2001 07:42 am, you wrote:
> > Hello,
> >
> > I tried this:
> >
> > data Nat = Zero | Succ Nat
> >
> > instance Enum Nat where
> > fromEnum Zero = 0
> > fromEnum (Su
The error is here:
At 2001-06-29 00:42, Michael Ackerman wrote:
>toEnum n = if n > 0 then 1 + toEnum n
(toEnum n) :: Nat, so you can't do (+) on it unless (Num Nat), because
(+) is a member of the Num class.
Obviously you want
--