Alex wrote:

 | > > class Aggregate a where
 | > >  toList::(Num b)=>a->[b]
 | > >  fromList::(Num b)=>[b]->a

Lennart replied:

 | The type of toList in the class declaration claims that it can
 | produce a list of any type in Num, but with MyAgg you can only get
 | a list of Int.

The problem here is that Haskell automatically "casts" a literal int (like
"7" , or "28") to anything of type Num, where (understandably) this
casting is not going on for variables of type Int in your program.

This is very confusing for beginners. It happened several times that
my students got into problems with this. The problem is that _if_ it
happens, it is often a quite ununderstandable error message.

Koen.

--
Koen Claessen,
[EMAIL PROTECTED],
http://www.cs.chalmers.se/~koen,
Chalmers University of Technology.


Reply via email to