instance overlap in 6.6 candidate

Serge D. Mechveliani mechvel at botik.ru
Mon Sep 4 10:22:34 EDT 2006


To my request on overlapping instances in 6.6 candidate
Simon Peyton-Jones <simonpj at microsoft.com>  writes on 
4 Sep 2006 

> [..]
>
> GHC 6.6's story is that an instance declaration can only be overlapped
> if you compile that module with -fallow-overlapping-instances.  Since
> the list instance for Show was not compiled in this way, you can't
> overlap it.
>
> You may think this is annoying -- but it does mean that you can look at
> an instance declaration and see whether it might be overlapped, just by
> look at the flags for that module. 

But why to restrict the user, why one needs to detect which library 
instance can be overlapped? Why not to allow all of them to overlap?

Here is an example of how I alayws was using overlaps with standard 
instances.

------------------------------------------------
data Equation = ...
instance Show Equation where ...

instance Show [Equation] 
  where   
  showsPrec _ eqs =  <certain program which prints a list of equation
                      in a `nicer' way than by the default list printing
                     >
------------------------------------------------

This gives the user possibility to redefine a certain part of the 
library instance.
Is not  ghc-6.4.1  better at this point?

-----------------
Serge Mechveliani
mechvel at botik.ru


More information about the Glasgow-haskell-users mailing list