Heap overflow is not catched

2000-06-09 Thread Marcin 'Qrczak' Kowalczyk

grepping through sources suggests that nobody tried to implement this,
only the exception constructor exists... OTOH stack overflow works.

import Exception
main:: IO ()
main = print (length (l++l)) `catchAllIO` print
where l = [0::Int ..]

-- 
 __("Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/  GCS/M d- s+:-- a23 C+++$ UL++$ P+++ L++$ E-
  ^^  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK  5? X- R tv-- b+++ DI D- G+ e h! r--%++ y-





RE: Heap overflow is not catched

2000-06-09 Thread Simon Marlow

 grepping through sources suggests that nobody tried to implement this,
 only the exception constructor exists... OTOH stack overflow works.
 
 import Exception
 main:: IO ()
 main = print (length (l++l)) `catchAllIO` print
 where l = [0::Int ..]

Yes, I know: heap overflow is somewhat trickier than stack overflow.  If the
stack overflows, at least you know that by raising an exception you're going
to reduce the size of the stack, the same isn't true of heap overflow, so
you need some kind of "soft limit" after which the exception is thrown.

And which thread should get the exception?  All of them?  Just the one that
was allocating at the time?  The main thread?  (this reminds me of one of
the great open questions in OS design: if you run out of memory, which
process do you kill?).  Perhaps a thread should have to register in order to
receive the heapOverflow exception, or maybe you should install a "heap
overflow handler", like a signal handler.  Comments?

Cheers,
Simon




Re: Signals

2000-06-09 Thread Marcin 'Qrczak' Kowalczyk

Thu, 8 Jun 2000 18:26:27 -0700, William Lee Irwin III [EMAIL PROTECTED] pisze:

 Is there a curses library in the works?

Yes, inside http://qrczak.ids.net.pl/Haber-0.2.tar.gz (requires ghc-4.07).

-- 
 __("Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/  GCS/M d- s+:-- a23 C+++$ UL++$ P+++ L++$ E-
  ^^  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK  5? X- R tv-- b+++ DI D- G+ e h! r--%++ y-





When is an occurrence an occurrence

2000-06-09 Thread Simon Peyton-Jones

Gentle Haskellers,

Here's a Haskell98-typo question.

Consider this program:

module M where

reverse xs = Prelude.reverse (tail xs)

foo ys = M.reverse ys

This is legal Haskell98.  The call to Prelude.reverse and to M.reverse
must both be qualified, because plain 'reverse' would be ambiguous.
But the definition of reverse does not need to be qualified, becuase it's
a definition!


Now, would it be legal to add this type signature to the end of M?

reverse :: [a] - [a]

Or should it be

M.reverse :: [a] - [a]

I can see two arguments

A) The unqualified form should be legal because the type signature 
can only refer to the 'reverse' defined in this module

B) The unqualified form is ambiguous.  All occurrences of 'reverse', 
other than the definition itself, must be qualified

The Report itself does not answer the question clearly,
so I propose to resolve the ambiguity.

Personally I'm inclined to resolve it in favour of (B).  In due course we
may want to allow type signatures for imported things in a module, for 
example.  Does anyone object?

Simon




RE: When is an occurrence an occurrence

2000-06-09 Thread Peter Douglass

The question I have is this.  In the example you gave the type signatures
for both versions of reverse are identical, are they not?  If they are
identical, I don't see the harm in not qualifying the type signatures.  On
the other hand, suppose they were not identical.  If there are no argument
types that would satisfy both versions, again there is no problem.  A
problem seems to arise when when the same argument could be applied to
either version.  So my question is, perhaps the qualifier could be required
in the type signature only if the type signatures are different?

 

 -Original Message-
 From: Simon Peyton-Jones [mailto:[EMAIL PROTECTED]]
 Sent: Friday, June 09, 2000 10:17 AM
 To: '[EMAIL PROTECTED]'
 Cc: Simon Peyton-Jones
 Subject: When is an occurrence an occurrence
 
 
 Gentle Haskellers,
 
 Here's a Haskell98-typo question.
 
 Consider this program:
 
   module M where
 
   reverse xs = Prelude.reverse (tail xs)
 
   foo ys = M.reverse ys
 
 This is legal Haskell98.  The call to Prelude.reverse and to M.reverse
 must both be qualified, because plain 'reverse' would be ambiguous.
 But the definition of reverse does not need to be qualified, 
 becuase it's
 a definition!
 
 
 Now, would it be legal to add this type signature to the end of M?
 
   reverse :: [a] - [a]
 
 Or should it be
 
   M.reverse :: [a] - [a]
 
 I can see two arguments
 
 A) The unqualified form should be legal because the type signature 
   can only refer to the 'reverse' defined in this module
 
 B) The unqualified form is ambiguous.  All occurrences of 'reverse', 
   other than the definition itself, must be qualified
 
 The Report itself does not answer the question clearly,
 so I propose to resolve the ambiguity.
 
 Personally I'm inclined to resolve it in favour of (B).  In 
 due course we
 may want to allow type signatures for imported things in a 
 module, for 
 example.  Does anyone object?
 
 Simon
 




Re: When is an occurrence an occurrence

2000-06-09 Thread Ralf Hinze

| Gentle Haskellers,
| 
| Here's a Haskell98-typo question.
| 
| Consider this program:
| 
|   module M where
| 
|   reverse xs = Prelude.reverse (tail xs)
| 
|   foo ys = M.reverse ys
| 
| This is legal Haskell98.  The call to Prelude.reverse and to M.reverse
| must both be qualified, because plain 'reverse' would be ambiguous.
| But the definition of reverse does not need to be qualified, becuase it's
| a definition!
| 
| 
| Now, would it be legal to add this type signature to the end of M?
| 
|   reverse :: [a] - [a]
| 
| Or should it be
| 
|   M.reverse :: [a] - [a]
| 
| I can see two arguments
| 
| A) The unqualified form should be legal because the type signature 
|   can only refer to the 'reverse' defined in this module
| 
| B) The unqualified form is ambiguous.  All occurrences of 'reverse', 
|   other than the definition itself, must be qualified
| 
| The Report itself does not answer the question clearly,
| so I propose to resolve the ambiguity.
| 
| Personally I'm inclined to resolve it in favour of (B).  In due course we
| may want to allow type signatures for imported things in a module, for 
| example.  Does anyone object?

Since it's a Haskell 98 issue, I am in favour of (A):

reverse :: reverse :: [a] - [a]
reverse xs  =  Prelude.reverse (tail xs)

Alternative (B) looks rather ugly:

M.reverse   :: reverse :: [a] - [a]
reverse xs  =  Prelude.reverse (tail xs)

Cheers, Ralf




Re: When is an occurrence an occurrence

2000-06-09 Thread Keith Wansbrough

 Now, would it be legal to add this type signature to the end of M?
 
   reverse :: [a] - [a]
 
 Or should it be
 
   M.reverse :: [a] - [a]

Definitely (A), the unqualified form should be legal.  I always consider

foo :: [..type..]
foo  = [..defn..]

as a pair, and to require

M.foo :: [..type..]
foo= [..defn..]

would seem strange.

I'm with Ralf on this one.

--KW 8-)
-- 
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) ---:
: PhD Student, Computer Laboratory, University of Cambridge, UK. :
: Native of Antipodean Auckland, New Zealand: 174d47'E, 36d55'S. :
: http://www.cl.cam.ac.uk/users/kw217/ mailto:[EMAIL PROTECTED] :
::






Re: When is an occurrence an occurrence

2000-06-09 Thread Malcolm Wallace

Simon PJ writes:

   reverse :: [a] - [a]
 Or
   M.reverse :: [a] - [a]

 A) The unqualified form should be legal because the type signature 
   can only refer to the 'reverse' defined in this module
 
 B) The unqualified form is ambiguous.  All occurrences of 'reverse', 
   other than the definition itself, must be qualified

 Personally I'm inclined to resolve it in favour of (B).  In due course we
 may want to allow type signatures for imported things in a module, for 
 example.  Does anyone object?

Yes, I object fairly strongly.  There can be no prospect of Haskell'98
allowing type signatures for imported values (even if it is adopted
for Haskell-2), because that would be a major language change.
Proposed fix B breaks currently-legal programs.  Proposed fix A breaks
no programs, and is fully consistent with the current Report.

Regards,
Malcolm





RE: When is an occurrence an occurrence

2000-06-09 Thread Erik Meijer

 Since it's a Haskell 98 issue, I am in favour of (A):
 
   reverse :: [a] - [a]
   reverse xs  =  Prelude.reverse (tail xs)
 
 Alternative (B) looks rather ugly:
 
   M.reverse   :: reverse :: [a] - [a]
   reverse xs  =  Prelude.reverse (tail xs)
 
 Cheers, Ralf

I completely agree.

Erik 




Re: When is an occurrence an occurrence

2000-06-09 Thread Robert Jeschofnik

On 09-Jun-2000, Simon Peyton-Jones [EMAIL PROTECTED] wrote:

 A) The unqualified form should be legal because the type signature 
   can only refer to the 'reverse' defined in this module
 
 B) The unqualified form is ambiguous.  All occurrences of 'reverse', 
   other than the definition itself, must be qualified

I think that I too am leaning towards option B, however I think that there
may be reason to go even a bit further than this, and require the definition
to be qualified, as well. (this would be restricted to ambiguous names only,
of course)

M.reverse :: [a] - [a]
M.reverse xs = Prelude.reverse (tail xs)


or is this too much baggage?


Rob




Re: When is an occurrence an occurrence

2000-06-09 Thread Matt Harden

Me too, for (A)!  (B) looks too ugly for me.  A type declaration should
refer to the "most local" definition of the name.  I think of the type
declaration, though optional, as being _part of_ the definition, so the
name should look the same.

Btw, why would one declare the type of a function defined outside the
current module?  For documentation only?  I would just use a comment if
that's the case.  IMHO, if allowed, such declarations should always have
to be qualified to avoid confusion.

Matt

P.S.   M.reverse line corrected below.

  Since it's a Haskell 98 issue, I am in favour of (A):
 
reverse :: [a] - [a]
reverse xs  =  Prelude.reverse (tail xs)
 
  Alternative (B) looks rather ugly:
 
M.reverse   :: [a] - [a]
reverse xs  =  Prelude.reverse (tail xs)
 
  Cheers, Ralf
 
 I completely agree.
 
 Erik




Re: When is an occurrence an occurrence

2000-06-09 Thread Matt Harden

Simon Peyton-Jones wrote:
 
 Gentle Haskellers,
 
 Here's a Haskell98-typo question.
 
 Consider this program:
 
 module M where
 
 reverse xs = Prelude.reverse (tail xs)
 
 foo ys = M.reverse ys
 
 This is legal Haskell98.

OK, I believe you that it's legal Haskell98, but Hugs98-sep99 doesn't
accept it.  Maybe the report should read that if you're going to define
reverse in your module, you must "import Prelude hiding (reverse)", and
leave it at that.  It eliminates the ambiguity by making it explicit
that Prelude.reverse cannot be referred to unqualified.  And you don't
have to change Hugs.

Thanks,
Matt Harden




Re: When is an occurrence an occurrence

2000-06-09 Thread Matt Harden

I (Matt Harden) wrote:
 
 Simon Peyton-Jones wrote:
 
  Gentle Haskellers,
 
  Here's a Haskell98-typo question.
 
  Consider this program:
 
  module M where
 
  reverse xs = Prelude.reverse (tail xs)
 
  foo ys = M.reverse ys
 
  This is legal Haskell98.
 
 OK, I believe you that it's legal Haskell98, but Hugs98-sep99 doesn't
 accept it.  Maybe the report should read that if you're going to define
 reverse in your module, you must "import Prelude hiding (reverse)", and
 leave it at that.  It eliminates the ambiguity by making it explicit
 that Prelude.reverse cannot be referred to unqualified.  And you don't
 have to change Hugs.

OK, now I have reread the report, and it says:
 The rules about the Prelude have been cast so that it is possible
 to use Prelude names for nonstandard purposes; however, every
 module that does so must have an import declaration that
 makes this nonstandard usage explicit.

So the report already reads as I suggested.  It seems to me that the
program above is not legal Haskell98, and there is no issue with
ambiguity of type declarations.  Have I missed something?

Thanks,
Matt