[Haskell-cafe] Why is toRational a method of Real?

Henning Thielemann lemming at henning-thielemann.de
Thu Aug 5 07:55:30 EDT 2010

On Thu, 5 Aug 2010, David Virebayre wrote:

> On Thu, Aug 5, 2010 at 1:11 PM, John Meacham <john at repetae.net> wrote:
>> use. This isn't to say ghc is doing the wrong thing, I don't think there
>> really is a right thing to do here given the broken class specifications
>> in the report.
> I often read that the numerical classes are problematic.
> At the same time, there are many programs and packages that rely on
> Haskell being that way.

I think the numeric type classes of Haskell 98 are better than the way of 
handling numbers in most other existing languages. They are ok for the 
applications that do not need polymorphic numeric types.

> What would it take to redesign the numeric class so that the new
> design eventually becomes the new Haskell standard ? ( not just an
> alternative prelude )
> Is it doable at all ?
> Would a first step be trying to compile all of hackage with the
> numeric prelude and see what breaks ?

Almost nothing would compile, because the organization is too different, 
not to speak of the more mathematically oriented names of the classes.

> If it's doable, how many years would it take to make it happen ?

All functions that use polymorphic numeric types would have to be adapted. 
However it would be a great test case for a refactoring tool!

It's even worse: The NumericPrelude is in progress, certainly currently 
better than Haskell 98's type classes, but there are known problems. 
Sometimes new numeric types are implemented and require to refine or 
restructure the classes, again. And there are not only problems with the 
numeric type classes, think of Functor, Applicative, Monad, and so on. In 
my opinion before trying to move to an improved numerical type hierarchy 
we should have class aliases designed, implemented and thoroughly tested 
in GHC.

More information about the Haskell-Cafe mailing list