
8 Jul
2010
8 Jul
'10
9:29 a.m.
On Thursday 08 July 2010 15:20:13, Pasqualino "Titto" Assini wrote:
Hi,
I just noticed that in ghci:
data Test = Test String
instance Show Test
show $ Test "Hello"
Will result in infinite recursion.
Is this a known bug?
It's not a bug. There are default methods in Show for show in terms of showsPrec and for showsPrec in terms of show. You need to define at least one of the two to get a working Show instance, otherwise trying to evaluate (show stuff) will lead to infinite recursion, it's the same with e.g. Eq. Might be a worthwhile feature request to let the compiler emit a warning on every instance declaration where no method is defined.
Thanks,
titto