> I have defined:
> 
> > class Aggregate a where
> >  toList::(Num b)=>a->[b]
> >  fromList::(Num b)=>[b]->a
> 
> > data MyAgg =Agg Int Int
> > instance Aggregate MyAgg where
> >  toList (Agg x y) = [x,y]
> >  fromList [x,y] = (Agg x y)
> 
> Hugs won't compile this because it says the declared type is too general.
> Any function that requires an Aggregate can use MyAgg.  Why am I
> getting an error?  
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.  So the type of toList in the class is more general
than the one you have given.
fromList has a similar problem.

        -- Lennart


Reply via email to