Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  GHCi bug? (Russ Abbott)
   2. Re:  GHCi bug? (Antoine Latter)
   3. Re:  GHCi bug? (Russ Abbott)
   4. Re:  GHCi bug? (Ozgur Akgun)
   5. Re:  GHCi bug? (Thomas Davie)


----------------------------------------------------------------------

Message: 1
Date: Mon, 15 Nov 2010 19:59:45 -0800
From: Russ Abbott <[email protected]>
Subject: [Haskell-beginners] GHCi bug?
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

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

*
*
Then enter Test at the prompt.
*
*

> Test
*
*

This seems to bomb GHCi. It isn't even interruptible but must be shut down
and restarted.
*
*
* -- Russ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101115/08d27093/attachment-0001.html

------------------------------

Message: 2
Date: Mon, 15 Nov 2010 23:10:18 -0600
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] GHCi bug?
To: [email protected]
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Mon, Nov 15, 2010 at 9:59 PM, Russ Abbott <[email protected]> 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


------------------------------

Message: 3
Date: Mon, 15 Nov 2010 21:12:17 -0800
From: Russ Abbott <[email protected]>
Subject: Re: [Haskell-beginners] GHCi bug?
To: Antoine Latter <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

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 <[email protected]> wrote:

> On Mon, Nov 15, 2010 at 9:59 PM, Russ Abbott <[email protected]>
> 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-0001.html

------------------------------

Message: 4
Date: Tue, 16 Nov 2010 11:44:38 +0000
From: Ozgur Akgun <[email protected]>
Subject: Re: [Haskell-beginners] GHCi bug?
To: [email protected]
Cc: Haskell Beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

Unfortunately, yes.

On 16 November 2010 11:39, Russ Abbott <[email protected]> wrote:

> I'm not sure what you are saying here. Are you saying that it's not a bug
> that GHCi went into a coma when I file was loaded and a prompt entered?
> *
> -- Russ*
> ***
> *
> **
>
>
> On Tue, Nov 16, 2010 at 3:34 AM, Ozgur Akgun <[email protected]> wrote:
>
>>
>> On 16 November 2010 05:12, Russ Abbott <[email protected]> wrote:
>>
>>> 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*
>>>
>>
>> It would be *cool* for GHC to make an analysis about the instance methods
>> of a type class, and their default implementations to find the minimal
>> subset of methods you have to implement to get a valid (for some definition
>> of valid) instance declaration. But it doesn't do such a thing. And it is
>> not an easy task.
>>
>> GHC only warns you if you do not implement a method which doesn't have a
>> default implementation. In your example, this is not the case.
>>
>> Best,
>>
>> --
>> Ozgur Akgun
>>
>
>


-- 
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101116/58a76768/attachment-0001.html

------------------------------

Message: 5
Date: Tue, 16 Nov 2010 12:17:01 +0000
From: Thomas Davie <[email protected]>
Subject: Re: [Haskell-beginners] GHCi bug?
To: Ozgur Akgun <[email protected]>
Cc: [email protected], Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

To explain that further as to why it's not a bug...

GHCi's job is to run the code you enter.  You asked it to show a value, so it 
executed the show function (correctly).  The default implementation called 
showPrec, which invoked show, etc.

There may well be a missing feature here (to check of you implement nothing 
other than the defaults which are very likely to loop), but not a bug.

Bob

On 16 Nov 2010, at 11:44, Ozgur Akgun wrote:

> Unfortunately, yes.
> 
> On 16 November 2010 11:39, Russ Abbott <[email protected]> wrote:
> I'm not sure what you are saying here. Are you saying that it's not a bug 
> that GHCi went into a coma when I file was loaded and a prompt entered?
> 
> -- Russ
> 
> 
> 
> 
> On Tue, Nov 16, 2010 at 3:34 AM, Ozgur Akgun <[email protected]> wrote:
> 
> On 16 November 2010 05:12, Russ Abbott <[email protected]> wrote:
> 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
> 
> It would be cool for GHC to make an analysis about the instance methods of a 
> type class, and their default implementations to find the minimal subset of 
> methods you have to implement to get a valid (for some definition of valid) 
> instance declaration. But it doesn't do such a thing. And it is not an easy 
> task.
> 
> GHC only warns you if you do not implement a method which doesn't have a 
> default implementation. In your example, this is not the case.
> 
> Best,
> 
> -- 
> Ozgur Akgun
> 
> 
> 
> 
> -- 
> Ozgur Akgun
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101116/550ebf5f/attachment.html

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 29, Issue 20
*****************************************

Reply via email to