Strange error in show for datatype

Bjorn Lisper
Fri, 5 Oct 2001 11:16:24 +0200 (MET DST)

Hi again,

My question about my student's problem surely stirred an interesting and
clarifying discussion. Still, I have a question.

Reconsider the example. There's a data type 

data LispList t = Atom t | LispList [LispList t] | Str [Char]

and an instance declaration

instance Show t => Show (LispList t) where
    show (Atom t) = show t
    show (LispList t) = show t
    show (Str t) = show t

So, hypothetically there could have been an additional, overlapping instance
declaration, say

instance Show (LispList Int) where
    show (Atom t) = show t
    show (LispList t) = show t
    show (Str t) = "Blahonga!"

Then we cannot know whether show (Str "HEJ") should yield "HEJ" or
"Blahonga!". However, my student never gave such an overlapping instance,
only the first. So far as I can see there should relly be no ambiguity here!
I'd really like to know what the cause of the problem is.

Björn Lisper