Le Jeudi 23 Janvier 2003 06:40, Matthew Donadio a �crit :
> Hi all,
>
> I have yet another question.  I think I have too much time on my hands.
>
> I have two functions:
> > rf     :: (RealFloat a, Integral b) => [a] -> b -> Complex a
> > rf x k = ...
> >
> > cf     :: (RealFloat a, Integral b) => [Complex a] -> b -> Complex a
> > cf x k = ...
>
> I would like to add these to the class system so I can create an
> overloaded version, f.
>
> From my understanding of the Report, the following should work, but I
> get an error, which I really don't understand.
>
> > class (Fractional a) => Floating a where
> >     f :: (Integral b) => [a] -> b -> a
> >
> > instance (RealFloat a) => Floating a where
> >     f x k = rf x k
> >
> > instance (RealFloat a) => Floating (Complex a) where
> >     f x k = cf x k
>
> hugs98 spits out
>
>       ERROR "f.lhs":59 - Syntax error in instance head (constructor
> expected)
>
> where line 59 is the first instance declaration.  Can anyone give me
> some guidance, or hints, here?
>
> Thanks a million.

On the first "instance" you're trying to instantiate "any type a that is a 
instance of RealFloat". 
AFAIK you can instantiate only "real" data types like "Complex a". (sorry for 
the "real" that is not the good term, but I'm just waking up :) )

-- 
Ciao

Jo

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to