Proposal: Remove Show and Eq superclasses of Num
Paterson, Ross
R.Paterson at city.ac.uk
Sat Sep 17 01:37:45 CEST 2011
Ian Lynagh writes:
> It doesn't solve everything, but I hope we can agree it is an
> incremental step in the right direction. I don't think a revolutionary
> change fixing all the issues is feasible. This particular blemish was
> already being described as "largely historical" more than a decade ago:
> http://www.haskell.org/pipermail/haskell/2000-October/006147.html
All these blemishes have been described as historical for a long time.
But I'm suggesting that we address them by going in a different direction.
Under this proposal the 7 numeric classes lose the Show superclass,
and Num, Fractional and Floating lose the Eq superclass. That breaks
compatibility with Haskell 98, and will break functions that have
numeric classes in their signatures and use equality or show in their
implementations (e.g. the patches need to change the signatures of
27 functions in ghc and the core libs). If we're considering that,
we ought also to consider alternative trade-offs between interface
improvement and breakage.
The alternative approach is to refactor the numeric classes internally
(as in the yap package). That will break packages too, probably more,
but that will leave us with much more sensible and useful classes.
And the breakage falls on different users:
- If we remove superclasses of Num, it falls on (some) people who put
numeric classes in their type signatures.
- If we refactor the numeric classes internally, it falls on those who
define instances of numeric classes. (I would argue that many of those
instances are kludged today because of the flawed classes.) Those
who merely use the numeric classes in type signatures or call their
methods should be unaffected.
More information about the Libraries
mailing list