X-Comment1: #############################################################
X-Comment2: #     uk.ac.glasgow.cs has changed to uk.ac.glasgow.dcs     #
X-Comment3: #     If this address does not work please ask your mail    #
X-Comment4: #     administrator to update your NRS & mailer tables.     #
X-Comment5: #############################################################

David Barton writes (edited):

> 
> class (Floating a) => Complex a where
>       realPart,imagPart :: a -> Float
> 
> I have the following as a first cut:
> 
> 
> instance (RealFloat a)  => Complex (CartComp a) where
>     realPart (x:!+y)    = x
>     imagPart (x:!+y)    = y
> 
> The gurus here will immediately (I trust) recognize that I have typing
> errors in this.  The type of Float does not match the general
> RealFloat in the instance definition.

Can't you just explicitly coerce x/y to Float using fromRealFrac?
i.e.,

        realPart (x:!+y)  = fromRealFrac x

Kevin

Reply via email to