"Stefan Kurtz" <[EMAIL PROTECTED]> writes: > > Consider the following script: > > >data T12 a = C1 | C2 a > > >instance (Show a) => Show (T12 a) where > > showsPrec p (C2 c) = showString "This is C2 ".shows c > > showsPrec p C1 = showString "This is C1" > > >data T1 a = C > > >instance Show (T1 a) where > > showsPrec p C = showString "This is C" > > and the evaluations: > > ? C > This is C > ? C2 1 > This is C2 1 > > which is as supposed. But > > ? C1 > ERROR: Cannot find "show" function for: > *** expression : C1 > *** of type : T12 a > > seems to be an error, since I have defined a show-instance for C1. This is not a bug in Hugs - or if it is a bug, it's a bug in Haskell. The problem is that C1 has type "T12 a". So what Show instance should we use for it? Here's some of the (infinite number of) choices: T12 Int T12 Float T12 Char T12 [Int] T12 [[Int]] .. It might seem that any choice we made would give the same result. That would be true in this example but there are some very obscure degenerate cases where different choices could give different results - very bad! All this is very unfortunate (especially as "show []" is an even simpler example of this phenomenon) - but it's not really clear what we can do about it. -- Alastair Reid Yale Haskell Project Hacker [EMAIL PROTECTED] http://WWW.CS.Yale.EDU/homes/reid-alastair/
