RE: Confusing GHC error message

2001-11-26 Thread Simon Peyton-Jones

Yes, good point.  I've improved the error message. It now reports a 
malformed class declaration.

S

| -Original Message-
| From: George Russell [mailto:[EMAIL PROTECTED]] 
| Sent: 23 November 2001 13:22
| To: [EMAIL PROTECTED]
| Subject: Confusing GHC error message
| 
| 
| (Yes, I know that's not very impressive, but you must all 
| have been wondering what's happened to me.)
| 
| The attached file, when compiled with ghc5.02.1, 
| -fglasgow-exts -fallow-overlapping-instances 
| -fallow-undecidable-instances produces the error message
|Haskell.hs:11: Illegal left hand side in data/newtype 
| declaration This is rather confusing, as the error comes not 
| from the data declaration in the file, but because on the 
| next line class was accidentally typed, rather than instance.
| 

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RE: (no subject)

2001-11-26 Thread Simon Marlow


 i use green-card with ghc's FFI export to sth like
   
   Haskell  - C -- Haskell
 
 the program is just arithmatic operations. the program seg fault
 in the callback from C to Haskell. anyone whether it is a bug?

There aren't any known bugs, but there are many known pitfalls.  You'll
need to give us more information, at least: the code that causes the
crash (preferably a small example), the exact GHC command lines used to
compile it, your GHC version, your machine and OS version.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: GHC garbage collector

2001-11-26 Thread Simon Marlow


 I have some code that uses FFI capabilities to associate 
 previously allocated
 memory with a structure akin to a ByteArray and allows 
 Haskell land to read
 and write to the C side of things.
 
 I use ForeignPtr and associate a destructor to allow the GHC's garbage
 collector to clean up after it figures out that the structure 
 is no longer
 being used. I know I am in funny territory.
 
 In some instances (when benchmarking) GHC takes its time 
 getting around to
 garbage collecting. Can someone suggest hooks to encourage 
 GHC to clean up
 things? Or better still functions to instruct GHC to garbage 
 collect specific
 structures (by calling relevant destructors)? Also comments 
 on how safe this
 whole business is.

IOExts.performGC will cause a full garbage collection to be performed.
If you want to be sure the finalizer has run to completion, you'll need
to set up some synchronisation between the main thread and the finalizer
using MVars. Finalizers have no special scheduling properties; they just
run concurrently with the other threads in the system.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: (no subject)

2001-11-26 Thread Yu Chen

hi,
   i've found the reason with someone's help. it is because i used
%code instead of safecode in the gc file where i did callback.
   thanks!


chenyu

-- Original Message --
From: Simon Marlow [EMAIL PROTECTED]
Date: Mon, 26 Nov 2001 09:42:39 -


 i use green-card with ghc's FFI export to sth like
   
   Haskell  - C -- Haskell
 
 the program is just arithmatic operations. the program seg fault
 in the callback from C to Haskell. anyone whether it is a bug?

There aren't any known bugs, but there are many known pitfalls.  You'll
need to give us more information, at least: the code that causes the
crash (preferably a small example), the exact GHC command lines used to
compile it, your GHC version, your machine and OS version.

Cheers,

Simon


___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Socket library ghc 5.02.1

2001-11-26 Thread Sigbjorn Finne


 Sven Eric Panitz [EMAIL PROTECTED] writes:
 
 It seems that the Socket library does still not work
 with ghc 5.02.1.
 I tried the simple test:
 
  main =
  do
  d - connectTo localhost (PortNumber 80)
  hPutStr d GET / HTTP/1.0\n\n
  hFlush d
  c - hGetContents d
  putStr c
 
 On Windows2000 I get the known error:
 
 *** Exception: does not exist
 Action: getProtocolByName
 Reason: no such protocol entry
 

(You, of course, need to wrap up that code with Socket.withSocketDo
to start up WinSock first).

FYI, in case you're planning on doing socket programming with GHC-5.02
on a Win32 platform, stay away from using the higher-level Socket module,
since its IO.Handle based view of sockets is just broken. Stick with the
lower-level SocketPrim interface instead.

Specifically, stay away from using the following:

   * Socket. connectTo
   * Socket.accept
   * Socket.sendTo
   * Socket. recvFrom
   * SocketPrim.socketToHandle

--sigbjorn



___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: heap and walking through a very long list

2001-11-26 Thread Simon Peyton-Jones

You can do it specifically for GHC, not not in standard Haskell (except
grossly inefficiently).
To see how to do it in GHC, look at the implementation in the source
code (ghc/lib/std),
which is online (check the CVS repository link on GHC's home page).

Meanwhile you could use the IArray stuff.

Simon

| -Original Message-
| From: Joe English [mailto:[EMAIL PROTECTED]] 
| Sent: 25 November 2001 00:12
| To: [EMAIL PROTECTED]
| Subject: Re: heap and walking through a very long list
| 
| 
| 
| Simon Peyton-Jones wrote:
| 
|  There should really be a strict accumArray, just as there 
| should be a 
|  strict foldl.
| 
| Yes, please!
| 
| Is there a way to write a strict version of accumArray in 
| Haskell 98, or does this need to be done by the implementation?
| 
| 
| --Joe English
| 
|   [EMAIL PROTECTED]
| 
| ___
| Haskell mailing list
| [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
| 

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Library report examples

2001-11-26 Thread Ian Lynagh


Hi guys,

The library report defines

  -- Diagonal of a square matrix
  diag :: (Ix a) = Array (a,a) b - Array a b
  diag x = ixmap (l,u) (\i-(i,i)) x
   where ((l,l'),(u,u')) | l == l'  u == u'  = bounds x

but ghc, hugs and nhc98 all loop (trying to get and test the value of l
I believe).


I am also curious why, for example,

  row :: (Ix a, Ix b) = a - Array (a,b) c - Array b c
  row i x = ixmap (l',u') (\j-(i,j)) x where ((l,l'),(u,u')) = bounds x

isn't written as

  row :: (Ix a, Ix b) = a - Array (a,b) c - Array b c
  row i x = ixmap (l,u) (\j-(i,j)) x where ((_,l),(_,u)) = bounds x
   ~~~~~~   ~~~


Thanks
Ian


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



List module in library report exports []((:), [])

2001-11-26 Thread Ian Lynagh


Hiyas

A few more things I'm afraid  :-(

The List module in the library report exports []((:), []) which, as I
mentioned in a previous thread WRT the GHC prelude, the report doesn't
allow in the exports list.

The block at the top listing the exports and types has been split into 2
at an apparently arbitrary point for no obvious reason?

deleteFirstsBy has no corresponding deleteFirsts and is not mentioned in
the text. Actually, having looked at the definitions it seems to be what
we would like to call \\By, so this should be noted in the By section.

insert and the zip/unzip stuff is also not explained in the text - don't
know if this is deliberate or not (insert is also mentioned with sort).

sortBy is mentioned before the By section unlike the other By variants
for no obvious reason.

exmaple

genericIndex seems to be a generic !!, but
The prefix generic indicates an overloaded function that is a
generalised version of a Prelude function.
and index is something completely different and defined in Ix. Clearly
the function can't be called generic!!, so I suggest the non-uniformity
be noted.

I am also curious as to why other functions don't have generic
equivalents, e.g. elemIndex, findIndices - is it because they were also
not considered important enough (as per the By functions)?

The indentation of unfoldr, maximumBy and minimumBy seems to have gone
wrong with some things not being indented at all (only looked at the
HTML version).

I think
unionBy eq xs ys =  xs ++ foldl (flip (deleteBy eq)) (nubBy eq ys) xs
may be clearer written as
unionBy eq xs ys =  xs ++ deleteFirstsBy eq (nubBy eq ys) xs


Thanks
Ian


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Asynchronous Exceptions

2001-11-26 Thread Hannah Schroeter

Hello!

On Fri, Nov 23, 2001 at 09:38:35AM -, Simon Marlow wrote:

 [...]

 However, I agree that sometimes you really want to be able to do this,
 so perhaps we need another form of 'block' which doesn't allow *any*
 exceptions to be delivered, for those times when you know that the time
 spent waiting in an interruptible operation is going to be bounded.

But even things like putStr can block for an unbounded amount of
time. E.g. stdout is a pipe and the reader just doesn't read it for
n hours (n unknown), etc.

Kind regards,

Hannah.

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell