toEnum problem

Michael Ackerman ack@nethere.com
Fri, 29 Jun 2001 01:43:49 -0700


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 (Succ n) = 1 + fromEnum n
> >         toEnum 0 = Zero
> >         toEnum n = if n > 0 then 1 + toEnum n
> >                    else error "bah"
> 
> Don't you actually mean:
> 
>          if n > 0 then Succ (toEnum n) else error "bah"
> 
> in the last line?
> 
> -Levent.