[Haskell-cafe] RealFloat constraint on Complex type

Conal Elliott conal at conal.net
Tue May 20 17:25:51 EDT 2008

GHC's (maybe Haskell98's?) Complex type is defined with a RealFloat
constraint on type type itself, rather than on some of the instances and

    data (RealFloat a) => Complex a  = !a :+ !a

I think the practice of constraint in type definitions is generally
discouraged, and I'm wondering if there are reasons other than history for
having the constraint here.  Is removing it on the table for Haskell'?

I just got bit by what I think is a typical problem.  I added a VectorSpace
instance for 'Complex a' and discovered that my 'a' must be in RealFloat,
even though I use only zero, addition, subtraction, and scaling.

I suspect this gripe has been raised before ...

Thanks,  - Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080520/e8efce5a/attachment.htm

More information about the Haskell-Cafe mailing list