Strange error in show for datatype

Jan-Willem Maessen
Fri, 5 Oct 2001 11:24:47 -0400

Dylan Thurston <> points out my mistake:
> > Strictness alas matters.  Here's the witness:
> > 
> > class Num a => ZeroList a where
> >   consZero :: a -> [a]
> >   consZero _ = 0:xs
> Err, "Num a" is already a bad context by Simon's criterion because of
> "fromInteger", which is what ultimately causes the problem in this
> case.

Quite right.  I overlooked the fact that the superclass constraint
"Num a" implicitly includes all the methods of Num in ZeroList for
these purposes.

Olaf Chitil <> gives an example along the lines I
was attempting (which I've corrected slightly):

> instance Show MyType where
>   shows _ = ("element of my type" ++ )

The important thing here is that the non-strict shows method can make
up any result it likes.

I do think some sort of extended defaulting mechanism as suggested by
Thomas Hallgren would be useful.  Yes, we will occasionally choose
confusing interpretations of e.g. "" vs [].  On the other hand, I'm
sure we can warn when defaulting in this way.

But its not the magic bullet against the monomorphism restriction one
might have hoped for...

-Jan-Willem Maessen