'Convertible' class?

Dylan Thurston dpt@math.harvard.edu
Fri, 9 Feb 2001 12:05:09 -0500

You make some good arguments.  Thanks.  Let me ask about a few of them.

On Thu, Feb 08, 2001 at 04:06:24AM +0000, Marcin 'Qrczak' Kowalczyk wrote:
> Wed, 7 Feb 2001 15:43:59 -0500, Dylan Thurston <dpt@math.harvard.edu> pisze:
> > class Convertible a b where
> >     convert :: a -> b
> > 
> > So, e.g., fromInteger and fromRational could be replaced with
> > convert.  (But if you did the same thing with toInteger and toRational
> > as well, you run into problems of overlapping instances.
> ...
> And convert cannot be a substitute for fromIntegral/realToFrac,
> because it needs a definition for every pair of types.

Right.  Those could still be defined as appropriately typed versions
of 'convert . convert'.

> You can put Num a in some instance's context, but you can't
> put Convertible Integer a. It's because instance contexts must
> constrain only type variables, which ensures that context reduction
> terminates (but is sometimes overly restrictive). There is ghc's
> flag -fallow-undecidable-instances which relaxes this restriction,
> at the cost of undecidability.

Ah!  Thanks for reminding me; I've been using Hugs, which allows these
instances.  Is there no way to relax this restriction while
maintaining undecidability?

	Dylan Thurston