Strange error in show for datatype

Daan Leijen daan@cs.uu.nl
Thu, 4 Oct 2001 14:17:28 +0200


Koen Cleassen wrote:
> Indeed. And this is a perfect example of the fact that all
> this bottom-dictionary passing does not work. The type of
> the list still matters though:
>
>   Hugs> show ([] :: [Char])
>   "\"\""
>
>   Hugs> show ([] :: [Int])
>   "[]"

Koen is absolutely right.  A fundamental property of type-classes
is that you can *not* assign a meaning to the program independent
of its types. A haskell program is not always typeable when I erase
all type signatures because some programs are inherently ambigious,
like showing the empty list. As Koen shows, by giving a type signature
I can disambiguate the program and it indeed gives quite different
results with different type signatures.

A good discussion about this property of type-classes can be found in:

A Second Look at Overloading, Martin Odersky, Philip Wadler, and Martin
Wehr. In Proceedings, ACM Conference on Functional Programming and Computer
Architecture, La Jolla, CA, June 1995.

All the best,
    Daan.