[Haskell-cafe] bug in ghci ?
Daniel Fischer
daniel.is.fischer at web.de
Thu Jul 8 09:29:40 EDT 2010
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
More information about the Haskell-Cafe
mailing list