Mark says:

> > data Blah = Blah
> > type Tuple = (Blah,Int)
> 
> > instance Show Tuple where
> >   showsPrec _ _ _
> >     = error []
> 
>     No instance for: `Show Blah'
>         arising from use of `PrelBase.$mshowList', at tmp.lhs:8
> 
> I know that instances of classes shouldn't be types, but that's
> what was so neat about ghc-2.** : they allowed types here.

3.0 is more consistent here.  Suppose I write

        show (Blah,3)

should that show as a Tuple or as a (Blah,Int) pair?
What if it was (Show (Blah,3)::Tuple)?  Etc.  

Essentially, resolving overloading is incoherent if you 
allow overlapping instance decls.  

> So are types not longer allowed in instance declarations?

Yes they're allowed, but it's just as if you'd written the 
expanded type.  Any two instance decls that don't overlap are
allowed.  You can write

        instance C (Blah,Int) where ..
        instance C (Int,Int)  where ..
        instance C (Blah, Bool) where ...

since none of these overlap.  But Show does have an instance for
(a,b) so you are stuck.  By "overlap" I mean that the instance
types can be unified.

Einar says:

> With the good old 2.something compiler, I could overwrite
> the default definition of Show for lists and other type constructors, e.g.:
> 
> data Blah = Blah deriving (Read,Show)
> 
> instance Show [Blah] where
>   showsPrec d [] r =  r
>   showsPrec d _ r  = "bla bla ..." ++ r
> 
>     Duplicate or overlapping instance declarations
>       for `Show [Blah]'
>           at PrelBase.mc_hi and Blah.hs

Same issue.  Show [a] exists already and overlaps with Show [Blah].

There is a full discussion of the bad consequences of overlapping
instance decls in the multi-parameter type class paper
        http://www.dcs.gla.ac.uk/~simonpj/multi.ps.gz

3.0 is a bit more restrictive than 2.xx, but it is Righter I think.
Dissenting opinions welcome.

Simon


Reply via email to