[clean-list] Newbie error

panitz panitz@em.uni-frankfurt.de
Fri, 29 Dec 2000 23:30:03 +0000


looks like a simple indentation error you made:

the following will do (not tested):

instance toString Q
 where
  toString q
   | q.den==1 = toString q.num
   | otherwise = toString q.num +++ "/" +++ toString q.den


As far as I know the guards of a function definition have to be
more indented than the function name in the function definition.

Sven Eric

----------
>Von: Zeno <zenem@earthlink.net>
>An: clean-list@cs.kun.nl
>Betreff: [clean-list] Newbie error
>Datum: Fre, 29. Dez 2000 18:57 Uhr
>

> When compiling the following code for a rational number class from
> Chapter 4 of "Functional Programming in Clean", I get an error
> "[<non-type-def>]: <hash-guarded-alt> expected instead of '}'"...
>
> :: Q = { num :: Int, den :: Int }
>
> instance toString Q
> where toString q
>  | q.den==1 = toString q.num
>  | otherwise = toString q.num +++ "/" +++ toString q.den
>
> (The error is on the first guarded line.)  Can anyone tell me why I'm
> getting this error?
>
> Thank you,
>    - Zeno
>
> _______________________________________________
> clean-list mailing list
> clean-list@cs.kun.nl
> http://www.cs.kun.nl/mailman/listinfo/clean-list