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.  Re: Apparent bug (Russ Abbott)
   2. Re:  Re: Apparent bug (Tobias Brandt)
   3. Re:  Re: Apparent bug (Edward Z. Yang)
   4. Re:  Re: Apparent bug (Tobias Brandt)
   5. Re:  Re: Apparent bug (Russ Abbott)
   6. Re:  Re: Apparent bug (Ozgur Akgun)


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

Message: 1
Date: Tue, 16 Nov 2010 09:52:17 -0800
From: Russ Abbott <[email protected]>
Subject: [Haskell-beginners] Re: Apparent bug
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I can understand "while(true) { }" producing an endless loop.  Can you
explain how the code I entered is interpreted to mean an unending cycle?
 Furthermore most systems can be interrupted, even when in a tight while(true)
{ } loop. In the example I gave, it seems that GHCi cannot be interrupted.
 (When I try it on some machines I get an out-of-memory error, but it
still(!) can't be interrupted.)

I think GHCi is wonderful software. But I doubt that anyone would claim that
it's bug-free. I'm surprised that there is so
much resistance to acknowledging what appears to be a bug.  Why not just fix
it?

To review, how should this be interpreted?

data Test = Test
instance Show Test    -- The problem occurs even without "where"

> Test

What interpretation justifies GHCi going into an uninterruptable state at
this point?
*
-- Russ *


On Tue, Nov 16, 2010 at 9:00 AM, <[email protected]> wrote:

> On 16 November 2010 12:17, Thomas Davie <[email protected]> wrote:
>
> > GHCi's job is to run the code you enter.
>
>
> Likewise, in many other languages when you write the following you'll get
> an
> infinite rule. And it just compiles (or gets interpreted) fine.
>
> while(true) { }
>
> Just another perspective.
>
> Ozgur
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101116/b1d84c22/attachment-0001.html

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

Message: 2
Date: Tue, 16 Nov 2010 19:12:12 +0100
From: Tobias Brandt <[email protected]>
Subject: Re: [Haskell-beginners] Re: Apparent bug
To: [email protected]
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hi Russ,

On 16 November 2010 18:52, Russ Abbott <[email protected]> wrote:
> I think GHCi is wonderful software. But I doubt that anyone would claim that
> it's bug-free. I'm surprised that there is so
> much resistance to acknowledging what appears to be a bug.  Why not just fix
> it?
> To review, how should this be interpreted?
>
> data Test = Test
> instance Show Test    -- The problem occurs even without "where"
>
>> Test
>
> What interpretation justifies GHCi going into an uninterruptable state at
> this point?
> -- Russ

It's not a bug but it should give a warning. The reason why this
compiles is that
there are default implementations for all members of the Show class.
Unfortunately,
they are defined in terms of them selves (show uses shows uses
showPrec uses show).
You have to define at least one to not get caught in an endless loop.
But there is
no way for GHC to know that.

Regards,
Tobias


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

Message: 3
Date: Tue, 16 Nov 2010 13:17:00 -0500
From: "Edward Z. Yang" <[email protected]>
Subject: Re: [Haskell-beginners] Re: Apparent bug
To: Tobias Brandt <[email protected]>
Cc: "Russ.Abbott" <[email protected]>, beginners
        <[email protected]>
Message-ID: <1289931361-sup-4...@ezyang>
Content-Type: text/plain; charset=UTF-8

It seems to me that there is a possibility we could reify some information
that is traditionally specified in the documentation: that is, what
functions must be defined by a minimal instance, which could then give
GHC enough information to give meaningful warnings if not all functions
for a minimal instance are proviced.

Edward


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

Message: 4
Date: Tue, 16 Nov 2010 19:27:55 +0100
From: Tobias Brandt <[email protected]>
Subject: Re: [Haskell-beginners] Re: Apparent bug
To: "Edward Z. Yang" <[email protected]>
Cc: "Russ.Abbott" <[email protected]>, beginners
        <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On 16 November 2010 19:17, Edward Z. Yang <[email protected]> wrote:
> It seems to me that there is a possibility we could reify some information
> that is traditionally specified in the documentation: that is, what
> functions must be defined by a minimal instance, which could then give
> GHC enough information to give meaningful warnings if not all functions
> for a minimal instance are proviced.

One could use a compiler pragma the defines possible sets of minimal
definitions, e.g.
{-# MINIMAL_DEF Num ((+),(*),abs,signum,fromInteger,(-)),
((+),(*),abs,signum,fromInteger,negate) #-}

one could even add logical notation, like:
{-# MINIMAL_DEF Num ((+), (*), abs, signum, fromInteger, (-) || negate) #-}


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

Message: 5
Date: Tue, 16 Nov 2010 10:40:33 -0800
From: Russ Abbott <[email protected]>
Subject: Re: [Haskell-beginners] Re: Apparent bug
To: matthew coolbeth <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

A few answers back, Matthew Coolbeth wrote,

(show v) where v is of type Test will evaluate to (showPrec v), and that
(showPrec v) will evaluate to (show v).  It should be clear that this is a
cyclic evaluation that will not terminate.


Presumably that was intentional. But why was that necessary?  It seems like
strange coding.  Furthermore, why isn't

instance Show Test

interpreted to mean

data Test = Test deriving (Show)

*
-- Russ *



On Tue, Nov 16, 2010 at 10:27 AM, Tobias Brandt
<[email protected]>wrote:

> On 16 November 2010 19:17, Edward Z. Yang <[email protected]> wrote:
> > It seems to me that there is a possibility we could reify some
> information
> > that is traditionally specified in the documentation: that is, what
> > functions must be defined by a minimal instance, which could then give
> > GHC enough information to give meaningful warnings if not all functions
> > for a minimal instance are proviced.
>
> One could use a compiler pragma the defines possible sets of minimal
> definitions, e.g.
> {-# MINIMAL_DEF Num ((+),(*),abs,signum,fromInteger,(-)),
> ((+),(*),abs,signum,fromInteger,negate) #-}
>
> one could even add logical notation, like:
> {-# MINIMAL_DEF Num ((+), (*), abs, signum, fromInteger, (-) || negate) #-}
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101116/05bed2d3/attachment-0001.html

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

Message: 6
Date: Tue, 16 Nov 2010 18:46:40 +0000
From: Ozgur Akgun <[email protected]>
Subject: Re: [Haskell-beginners] Re: Apparent bug
To: [email protected]
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

Hi,

On 16 November 2010 17:52, Russ Abbott <[email protected]> wrote:

> I'm surprised that there is so much resistance to acknowledging what
> appears to be a bug.  Why not just fix it?


I'd really like it, if ghci was clever enough to automatically detect the
fact that you haven't provided enough function definitions for the minimal
instance. Do you have a fix in mind?Other than something like annotating
class declarations, which is a cool idea and has been suggested by ezyang
already.

What interpretation justifies GHCi going into an uninterruptible state at
> this point?


This is really bad. It should still be interruptible. I think I can break my
resistance and say this (ghci not being interruptible) is a bug :)

Strangely, if you define two empty functions, just calling each other, this
infinite loop can be easily interrupted. Try it with:

f = g
g = f

Moreover, if you compile&run your original code, a very quick 'stack space
overflow' occurs. Nothing to interrupt there. At least it doesn't eat up all
your system resources as you say ghci does. I just killed the process, saved
before the need to restart :)

Best,
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101116/28dcde91/attachment.html

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

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


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

Reply via email to