[Haskell-beginners] GHCi bug?

Russ Abbott russ.abbott at gmail.com
Tue Nov 16 00:12:17 EST 2010


I know the code isn't correct. My point is that the compiler didn't complain
when the code was loaded, and the interpreter died when it was executed.
That shouldn't happen.
*
-- Russ*
***
*
**


On Mon, Nov 15, 2010 at 9:10 PM, Antoine Latter <aslatter at gmail.com> wrote:

> On Mon, Nov 15, 2010 at 9:59 PM, Russ Abbott <russ.abbott at gmail.com>
> wrote:
> > This looks like a GHCi bug.
> > Load a file with these two lines into GHCi
> >
> > data Test = Test
> > instance Show Test where  -- No body to the instance statement
> >
>
> A Show instance without a body isn't valid. Perhaps you wanted:
>
> > data Test = Test
> >  deriving Show
>
> If you take a look at the source for the Show class:
>
> http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/src/GHC-Show.html#Show
>
> you can see that the function 'show' has a default implmentation of
> 'show' in terms of 'showsPrec', whicle 'showsPrec' has a default
> implementation in terms of 'show', so you end up with an infinite
> loop.
>
> The idea is that you can pick which one to implement - but you do need
> to pick :-)
>
> Antoine
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20101116/1c6cc9e5/attachment.html


More information about the Beginners mailing list