CVS Repository

2005-09-14 Thread Peter Simons
Hi,

I understand the GHC CVS repository has moved recently? It
appears that the document

  http://www.haskell.org/ghc/docs/latest/html/building/sec-cvs.html

hasn't been updated accordingly; could someone with CVS
commit access please fix that?

Thanks,
Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: switching off let-floating

2005-07-28 Thread Peter Simons
Wolfgang Jeltsch writes:

 > where is this switch documented?

http://haskell.org/ghc/docs/latest/html/users_guide/flag-reference.html#id3128647

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Re[2]: error in your article? about meaning of safe/unsafe in "foreign import"

2005-05-20 Thread Peter Simons
Bulat Ziganshin writes:

 PS> Since pure FFI calls don't have any side-effects, they are
 PS> always safe to be called unsafely.

 > sorry, but even pure C function can call back to Haskell world and
 > lead to GC.

Um, right. I said I didn't understand these things
completely either. Guess I was right. ;-)

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: error in your article? about meaning of safe/unsafe in "foreign import"

2005-05-20 Thread Peter Simons
Duncan Coutts writes:

 > So to sumarise the pairings:
 >   * you _must_ make a safe call to an unsafe foreign function
 >   * you _may_ make an unsafe call to a safe foreign function
 >
 > It's a contravariance :-)

I'd use a slightly different term. Declaring a function that
needs special precaution to be called as "safe", and
declaring a function that is safe to be called anytime as
"unsafe" is contra-intuitive. ;-)

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: error in your article? about meaning of safe/unsafe in "foreign import"

2005-05-20 Thread Peter Simons
Bulat,

just for the record, it's not my article. Although I have the
privilege of sharing a somewhat similar name with the geniuses
around here, I didn't have any part in that text. ;-)

You were wondering about this declaration:

 >  foreign import ccall unsafe sin :: Float -> Float

I guess you are confused by the difference between safe/unsafe
FFI calls versus pure/impure FFI calls. Which is comforting
for me, because as it happens I don't quite understand that
either. ;-) I'll try to explain what I believe I do
understand, and hope that the others on this list chime in
case I mess something up.

A pure function is one without side-effects, meaning that the
result depends only on the function arguments. Those are
surprisingly few; the C function strlen(3) for example is
_not_ pure because it depends on the fact that the memory
pointed to by the argument actually contains the string
which's length you'd like to compute. So the strlen() call
must occur in the correct order in relation to other I/O calls
like as read(), malloc(), or whatever. Thus, the signature for
strlen() would be:

strlen :: Ptr CChar -> IO CSize

The sin(3) function on the other hand is pure. It doesn't
depend on anything but the floating point value you give it,
hence in can be evaluated at any point of the program
execution, hence it doesn't need to be in the IO monad:

sin :: CFloat -> CFloat

Now, safe and unsafe calls are a different beast:

 | A safe call is less efficient, but guarantees to leave the
 | Haskell system in a state that allows callbacks from the
 | external code. In contrast, an unsafe call, while carrying
 | less overhead, must not trigger a callback into the Haskell
 | system.

The vast majority of C function you will call are unaware of
Haskell. They will not trigger anything the Haskell runtime
system needs to know about, nor will they force a part of your
Haskell program to be evaluated. Those functions can be called
unsafely, just like the definition above says.

Since pure FFI calls don't have any side-effects, they are
always safe to be called unsafely. (Yes, the choice of the
words "safe" and "unsafe" is a bit unfortunate in the standard
here.) So unless I am very mistaken, the declaration

  foreign import ccall safe sin :: Float -> Float

would work just as well as the one above does, but it would be
less efficient.

In other words, if you declare a FFI function to be called
safely, and to be called from within the IO monad, then
absolutely nothing can possibly go wrong. ;-)


 > is it possible to download sources of http server mentioned
 > in this article?

I think the (more or less) latest version is here:

  http://www.mdstud.chalmers.se/~md9ms/hws-wp/

Another somewhat extensive example for system programming in
Haskell is available here:

  http://postmaster.cryp.to/

Hope this helps.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: not.hDuplicate

2005-05-15 Thread Peter Simons
Bulat Ziganshin writes:

 > one thread gives to another handle of open file. i need
 > to read some data from this file. how can i accomplish
 > this?

Keep the Handle in an MVar at all times, then access to it
will be synchronized between threads:

  
http://haskell.org/ghc/docs/latest/html/libraries/base/Control.Concurrent.MVar.html

If you need more background on this stuff, this paper is the
one you want to read:

  http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Can't compile GHC

2005-05-09 Thread Peter Simons
Daniel Carrera writes:

 > It's not often that it takes me more than a week to
 > compile a program.

You should have posted a short message to the list, asking
whether anyone happened to have a tar.gz archive with
Solaris binaries lying around that he can send you. I'm
willing to bet that would have been a lot faster than trying
to bootstrap the software yourself for a _week_, because the
"you need GHC to compile GHC" problem virtually ceases to
exist once you _have_ GHC.


 > At this point I decide that I'll teach people Python
 > instead of Haskell. I don't particularly like Python, but
 > hey, it works.

Why don't you use the NHC98 compiler you had already
running? Or Hugs98, which is self-contained?

I think it's a shame that your students don't get the chance
to learn a purely functional language just because the GHC
team doesn't have a volunteer to provide Solaris binaries.
Hint, hint. ;-)

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Haddock's -s switch is broken

2005-05-03 Thread Peter Simons
Simon Marlow writes:

 > Anyway, in CVS, the argument to -s is transformed as follows:
 >
 >   - the string %M is replaced by the module name
 > (with '.' replaced by '/')
 >
 >   - the string %F is replaced by the source file name
 >
 > so to get the behaviour of Haddock 0.6, you say 'haddock -s /%F'.

Very cool. Adding the '%F' did fix the problem; thanks for
the pointer.

I am all for having links to the source code wherever
possible, by the way, I think that's the right direction to
go. IMHO, the best solution would be generate the pages with
the source along with the documentation. This approach gets
rid of most file-name-guessing problems, and it allows for
nifty features to be added (such as adding hyperlinks in the
source code, too).

Doxygen, which seems to be C++'s Haddock on steroids, does
it this way and it works nicely.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Haddock's -s switch is broken

2005-05-02 Thread Peter Simons
Hi,

it appears that the '-s' switch in the CVS-HEAD version of
Haddock stopped working the way I know it. I run

  haddock -h -s . *.hs

to generate the documentation, and it does have the "Source
Code" link on every page, but the link points to the "."
_directory_, not to "./{module-name}.hs" file like it
should.

Am I doing something wrong or is this a bug?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Haddock chokes on '#'

2005-02-14 Thread Peter Simons
Simon Marlow writes:

 >>> (#):: a -> (a -> b) -> b
 >>> a # f  =  f a

 > Haddock parses GHC extensions by default, so its syntax
 > corresponds to GHC with -fglasgow-exts.

I see. Thanks for the clarification. Fortunately, writing ( # )
instead solves the problem. ;-)

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Haddock chokes on '#'

2005-02-11 Thread Peter Simons
Processing the file

> module Test where
>
> -- |Haddock chokes on this.
>
> (#):: a -> (a -> b) -> b
> a # f  =  f a

with Haddock 0.6 gives an error:

 | haddock test.hs
 | test.hs:5:3: Parse error

Since GHC deals with this code just fine, I suppose this is
a bug.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Unregistering a package

2005-02-10 Thread Peter Simons
Simon Marlow writes:

 > The general syntax of package ids is:

 >pkgid ::= pkg ('-' version)?
 >pkg ::= (alphanum|'-')+
 >version ::= (digit+) ('.' digit+)* ('-' alphanum+)*

Thanks. I gave my package the version "hsdns-0.0-2005-02-10"
and that fixed the problem.


 > Perhaps we should change the syntax of package ids
 > though?

In my humble opinion, GHC shouldn't try to guess what
version identifiers mean; I would treat them as a literal
strings without any parsing. But that's probably just me.

Anyway, thanks for the clarification.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Unregistering a package

2005-02-09 Thread Peter Simons
I have an interesting problem. There are two versions of the
HsDNS package installed right now:

 $ ghc-pkg list
 | /usr/local/ghc-current/lib/ghc-6.5/package.conf:
 | rts-1.0, [...]  (hsdns-2005-02-04),
 | hsdns-2005-02-08

Now how can I unregister them? I have tried everything I
could think of, but no luck:

 $ ghc-pkg unregister hsdns
 | ghc-pkg: package hsdns matches multiple packages:
 |   hsdns-2005-02-04, hsdns-2005-02-08

 $ ghc-pkg unregister hsdns-2005-02-08
 | ghc-pkg: cannot parse 'hsdns-2005-02-08' as a package identifier

Can someone give me a pointer how to remedy this situation?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Waiting on Sockets or File Descriptors

2005-02-03 Thread Peter Simons
Simon Marlow writes:

 > When you compile your program with -threaded, "safe" FFI
 > calls don't block other threads, but "unsafe" calls still
 > do. Basically a "safe" FFI call releases the lock on the
 > RTS so other Haskell threads can continue to run [...].

Thanks for the clarification.

If I understood this right, then I can use forkIO to run a
"safe" FFI function which blocks, but in the threaded RTS
this will not block all other FFI calls.

So what happens in the non-threaded RTS? Now the blocking
yet "safe" FFI invocation _would_ block other FFI calls but
not evaluation of "pure Haskell" code. Is that right?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Waiting on Sockets or File Descriptors

2005-02-02 Thread Peter Simons
Wolfgang Thaller writes:

 > a) poll() is not supported on Mac OS X and (at least some
 > popular versions of) BSD.

Are you certain? Just tried "man poll" on one of the MacOS X
machines the SourceForge compile farm offers, and that one
had it: "Darwin ppc-osx1 5.5 Darwin Kernel Version 5.5".


 > b) 'forkIO' in the threaded RTS would suffice in this
 > case, as the poll() or select() system calls don't use
 > any thread-local state. In the threaded RTS, "safe"
 > foreign imports never affect other threads [...].

That would be really good news! I assumed that GHC's runtime
system used one thread for _all_ FFI invocations? (Unless
you start new ones.) So I thought calling poll() would block
all other FFI invocations until it returned?

Or is that only for "unsafe" FFI calls?

Do you have an URL for me where I can find out more about
this, by any chance?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Waiting on Sockets or File Descriptors

2005-02-02 Thread Peter Simons
Tomasz Zielonka writes:

 >> Like select(2) or poll(2) would do?

 > You seem to what something low-level.

Well, my point is that I don't really want to deal with the
file descriptors. What I'd really like to do is to register
a call-back function; similar to the way signal handlers
work. I don't want to wait for something to happen -- I'd
like to be notified when something happens.

By the way, the source code for the module says:

  -- Note: threadDelay, threadWaitRead and threadWaitWrite
  -- aren't really functional on Win32, but left in there
  -- because lib code (still) uses them (the manner in which
  -- they're used doesn't cause problems on a Win32 platform
  -- though.)

So I guess I can't really use them in code that's supposed
to be portable among different platforms?

Maybe 'forkOS' combined with calling poll() through FFI
really is the best solution? I seem to recall reading
somewhere that the threaded RTS was more efficient for these
applications anyway?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Waiting on Sockets or File Descriptors

2005-02-02 Thread Peter Simons
Tomasz Zielonka writes:

 > threadWaitRead :: Int -> IO ()
 > threadWaitWrite :: Int -> IO ()

Thanks for the pointer!

Am I correct in assuming that there is no "more high-level"
mechanism for scheduling more than one file descriptor? Like
select(2) or poll(2) would do?

I guess, I could implement it on top of those functions with
some clever forkIO'ing, but I wonder whether that's
particularly efficient?

I'm asking because I am fairly certain that other people
will run into this problem too. It would be nice to have a
more generic mechanism for this purpose, particularly if it
will (eventually) be supported by other implementations as
well. I mean, all the necessary infrastructure is bound to
be available in the run-time system anyway.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ghc HEAD 'make html' problems

2005-02-01 Thread Peter Simons
Simon Marlow writes:

 > This was due to a bug in GHC introduced a few days ago
 > and fixed yesterday. Please try again.

I have tried again moments ago: same problem.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Waiting on Sockets or File Descriptors

2005-02-01 Thread Peter Simons
Hi,

I have the following problem: I use an external library
through the foreign function interface which gives me
_several_ sockets and expects me to call it again when any
of those sockets becomes readable or writable.

Since I know that the Haskell run-time system has all the
required functionality in place, I wonder whether there is
any way to register these sockets in the internal scheduler
and have it call an 'IO ()' function in case of such an
event?

What makes matters more complicated is that the _library_
owns these sockets -- not me. So I cannot really touch them
or lift them into a 'Handle'.

Any ideas?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


ghc HEAD 'make html' problems

2005-02-01 Thread Peter Simons
I can't build the library's Haddock documentation anymore:
the process fails claiming that Control/Arrow-raw.hs would
be missing. I've had this problem for a while now. Does
anybody else see this?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: More HaXml trouble

2005-01-14 Thread Peter Simons
Simon Marlow writes:

 > Looks like the HaXml package spec is missing a dependency
 > on haskell98.

You're right. That was it. Thanks!

Peter
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


More HaXml trouble

2005-01-14 Thread Peter Simons
Hi,

after rebuilding ghc-current, I got an intact Cabal version
and managed to install HaXml successfully. However, when I
try to link a program that actually uses the package, the
linker stage fails with these errors:

  
/usr/local/ghc-current/lib/HaXml-1.12.1/libHSHaXml-1.12.1.a(Combinators.o)(.text+0x3aa9):
 In function `__stginit_TextziXMLziHaXmlziCombinators_':
  : undefined reference to `__stginit_Maybe_'
  
/usr/local/ghc-current/lib/HaXml-1.12.1/libHSHaXml-1.12.1.a(Escape.o)(.text+0x22b9):
 In function `__stginit_TextziXMLziHaXmlziEscape_':
  : undefined reference to `__stginit_Char_'
  
/usr/local/ghc-current/lib/HaXml-1.12.1/libHSHaXml-1.12.1.a(Generate.o)(.text+0x37f1):
 In function `__stginit_TextziXMLziHaXmlziHtmlziGenerate_':
  : undefined reference to `__stginit_Char_'
  [...]
  collect2: ld returned 1 exit status
  *** Deleting temp files
  Deleting:

I've tried adding "-package base" to the command line, but
that didn't help. Any other idea?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: HaXml and ghc-current

2005-01-12 Thread Peter Simons
Ross Paterson writes:

 > CVS Cabal had the bug you describe

Alright, that was it. Thanks a lot for the pointer.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: HaXml and ghc-current

2005-01-11 Thread Peter Simons
Lemmih  writes:

 > You should probably talk to Malcolm Wallace about it.

Curiously enough, he sent me here. ;-) Oh well, looks like I
have to use my own brain.

Anyway, thanks a lot for trying to help, Lemmih. It is very
much appreciated.

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: HaXml and ghc-current

2005-01-10 Thread Peter Simons
Lemmih  writes:

 > But no worries; HaXml is cabalized and should be
 > available in your CVS source tree.

I see, thanks for the info! Any advice on how to
build/install it with Cabal? I've tried it, but when Cabal
tries to create the library, it appears to get the file
suffixes wrong:

 $ runghc Setup.lhs Setup.lhs build
 | Preprocessing HaXml-1.0...
 | Building HaXml-1.0...
 | [...]
 | /usr/bin/ar: creating dist/build/libHSHaXml-1.0.a
 | /usr/bin/ar: 'dist/build/src/Text/ParserCombinators/HuttonMeijerWallace..o': 
No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Combinators..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/DtdToHaskell/Convert..o': No 
such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/DtdToHaskell/Instance..o': No 
such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/DtdToHaskell/TypeDef..o': No 
such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Escape..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Haskell2Xml..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Html/Generate..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Html/Parse..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Html/Pretty..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Lex..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/OneOfN..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Parse..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Pretty..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Types..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Validate..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Verbatim..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Wrappers..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Xml2Haskell..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Xtract/Combinators..o': No such 
file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Xtract/Lex..o': No such file
 | /usr/bin/ar: 'dist/build/src/Text/XML/HaXml/Xtract/Parse..o': No such file
 | /usr/local/ghc-current/bin/ghc -odir dist/build/src/tools -hidir 
dist/build/src/tools -o dist/build/src/tools/Canonicalise --make -isrc/tools 
src/tools/Canonicalise.hs
 | Chasing modules from: src/tools/Canonicalise.hs
 | src/tools/Canonicalise.hs:
 | Could not find interface file for `Text.XML.HaXml.Wrappers'
 | (use -v to see a list of the files searched for)

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


HaXml and ghc-current

2005-01-10 Thread Peter Simons
Hi,

I've just tried to install HaXml with the latest GHC from
CVS, and the package compiles fine but the installation
procedure aborts with:

  ghc-pkg: cannot find package HaXml
  `cat ghcpkgcmd` --add-package http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: internal error: weird activation record found on stack: 9

2005-01-05 Thread Peter Simons
Simon Marlow writes:

 > you'll need to compile up a local copy of the
 > debug/threaded RTS so you can use -debug and
 > -threaded together. The way to do that is to
 > add "GhcRtsWays += thr_debug" to mk/build.mk in
 > a GHC tree, and build as normal.

Unfortunately, that didn't work. I've added the option:

  peti:/usr/local/src/ghc-current# cat ghc/mk/build.mk
  XMLDocWays  := html
  GhcRtsWays  += thr_debug
  SRC_CC_OPTS += -nopie -fno-stack-protector-all -fno-stack-protector
  SRC_HC_OPTS += -optc-nopie -optc-fno-stack-protector-all 
-optc-fno-stack-protector

But after building, there is no debug/threaded RTS:

  peti:/usr/local/src/ghc-current# find . -name *rts_*
  ./ghc/rts/libHSrts_p.a
  ./ghc/rts/libHSrts_thr.a
  ./ghc/rts/libHSrts_thr_p.a
  ./ghc/rts/libHSrts_debug.a

I've done a "make distclean" and built from the scratch,
too, but it didn't make a difference. I'm using GHC's CVS
HEAD.

Am I doing something wrong?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: internal error: weird activation record found on stack: 9

2005-01-04 Thread Peter Simons
Simon Marlow writes:

 > add "GhcRtsWays += thr_debug" to mk/build.mk in a GHC
 > tree, and build as normal.

Great, that's gonna be no problem.

Concerning your original instructions:

 | Please compile the program with -debug, then open it with
 | gdb. Set a breakpoint on barf() and run the program:
 |
 | gdb> break barf
 | gdb> run
 |
 | and wait for it to hit the breakpoint.  Then do
 |
 | gdb> signal SIGABRT
 |
 | to get a core dump. Send the source, binary, and core
 | dump to us. With any luck, we'll be able to track it down
 | without running the program.

I'll wait for the bug to occur again, before I'll do that,
okay? My GHC version was several weeks old, perhaps the bug
is gone (or looks different) in the most current GHC.

Thanks for the help!

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: internal error: weird activation record found on stack: 9

2005-01-03 Thread Peter Simons
I wrote:

 > Simon Marlow writes:

 >> Please compile the program with -debug, then open it
 >> with gdb.

 > Unfortunately, -debug seems to conflict with -threaded:

 >   ghc --make -threaded -debug -O -Wall [...] -o postmaster tutorial.lhs [...]
 >   Chasing modules from: tutorial.lhs
 >   [...]
 >   Compiling Main ( tutorial.lhs, .objs/Main.o )
 >   Linking ...
 >   /usr/lib/gcc-lib/i686-pc-linux-gnu/bin/ld: cannot find -lHSrts_thr_debug
 >   collect2: ld returned 1 exit status

It has been a while since this problem came up, and I was
wondering what to do now, because the software keeps
crashing (or freezing) every few days.

Any advice, anyone?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: OpenAL builds despite --disable-openal

2004-12-22 Thread Peter Simons
Volker Stolz writes:

 > Fix attached.

Thank you! Is this patch gonna make it into CVS?

Peter

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


OpenAL builds despite --disable-openal (was: Error building GHC: can't locate import `Package')

2004-12-20 Thread Peter Simons
I wrote:

 > I deleted it and said "make" again, and now it seems to work
 > (it's still building).

As it turned out, the build does not succeed. It fails while
trying to build OpenAL:

 | Sound/OpenAL/AL/BasicTypes.hs:63:15:
 | Not in scope: type constructor or class `HTYPE_ALFLOAT'
 |
 | Sound/OpenAL/AL/BasicTypes.hs:66:16:
 | Not in scope: type constructor or class `HTYPE_ALCLAMPF'
 |
 | Sound/OpenAL/AL/BasicTypes.hs:69:16:
 | Not in scope: type constructor or class `HTYPE_ALDOUBLE'
 |
 | Sound/OpenAL/AL/BasicTypes.hs:72:16:
 | Not in scope: type constructor or class `HTYPE_ALCLAMPD'
 | <>
 | make[2]: *** [Sound/OpenAL/AL/BasicTypes.o] Error 1
 | make[1]: *** [all] Error 1
 | make[1]: Leaving directory `/usr/local/src/ghc-current/libraries'

It shouldn't even build OpenOL, however, because I ran
./configure with "--disable-openal".

I see the flag in "libraries/config.log", so it has been
passed through alright. But ${SUBDIRS} contains the "OpenAL"
directory nonetheless afterwards.

Any ideas how to fix this? (Except for manually editing the
makefile?)

Peter

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


Re: internal error: weird activation record found on stack: 9

2004-12-18 Thread Peter Simons
Simon Marlow writes:

 > Please compile the program with -debug, then open it with
 > gdb.

Unfortunately, -debug seems to conflict with -threaded:

  ghc --make -threaded -debug -O -Wall [...] -o postmaster tutorial.lhs [...]
  Chasing modules from: tutorial.lhs
  [...]
  Compiling Main ( tutorial.lhs, .objs/Main.o )
  Linking ...
  /usr/lib/gcc-lib/i686-pc-linux-gnu/bin/ld: cannot find -lHSrts_thr_debug
  collect2: ld returned 1 exit status

Would compiling with -debug and without -threaded still
help?

Peter

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


Re: Error building GHC: can't locate import `Package'

2004-12-18 Thread Peter Simons
Sven Panne writes:

 > Hmmm, there is no ParsePkgConfLite.hs in the HEAD anymore. Perhaps you have
 > some old cruft lying around in your build directory?

I deleted it and said "make" again, and now it seems to work
(it's still building). Thank you.

It might be good to remove the file in the "clean" or
"distclean" targets, IMHO. I also noticed that
ghc/utils/ghc-pkg/.cvsignore lists it as an ignorable file,
which is why "cvs update" didn't show anything.

Peter

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


Error building GHC: can't locate import `Package'

2004-12-18 Thread Peter Simons
When building the current CVS HEAD with ghc-6.2.2 on
Linux/x86, I get this error:

  [...]
  ==fptools== make boot - --no-print-directory -r;
   in /usr/local/src/ghc-current/ghc/utils/ghc-pkg
  
  Creating Version.hs ...
  ghc-6.2.2 -M -optdep-f -optdep.depend -osuf o
-optdep--exclude-module=Compat.RawSystem
-optdep--exclude-module=Compat.Directory
-optdep--exclude-module=Distribution.Compat.Error
-optdep--exclude-module=Distribution.Compat.ReadP
-optdep--exclude-module=Distribution.Extension
-optdep--exclude-module=Distribution.InstalledPackageInfo
-optdep--exclude-module=Distribution.License
-optdep--exclude-module=Distribution.Package
-optdep--exclude-module=Distribution.ParseUtils
-optdep--exclude-module=Distribution.Setup
-optdep--exclude-module=Distribution.Version
-optdep--exclude-module=System.FilePath -H16m -O
-optc-nopie -optc-fno-stack-protector-all
-optc-fno-stack-protector -cpp -Wall
-fno-warn-name-shadowing -fno-warn-unused-matches
-i../../lib/compat Main.hs ParsePkgConfLite.hs Version.hs
  ParsePkgConfLite.hs: can't locate import `Package'

It seems that ParsePkgConfLite.hs omits the "Distribution"
part when importing Distribution.Package. 

Peter

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


internal error: weird activation record found on stack: 9

2004-12-16 Thread Peter Simons
Hi,

I'm getting this error in my software every now and then:

  postmaster: internal error: scavenge_stack: weird activation record found on 
stack: 9
  Please report this as a bug to [EMAIL PROTECTED],
  or http://www.sourceforge.net/projects/ghc/

The process runs just fine for several days, and then it
crashes with this message out of the sudden. There is no
apparent cause. I'm using a fairly recent CVS ghc to compile
the program on Linux/x86.

Any idea what I can do to help tracking this bug down?

Peter

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


Re: Bug in touchForeignPtr?

2004-11-24 Thread Peter Simons
Duncan Coutts writes:

 > you cannot solve the finalisers problem just by running
 > the finaliser thread to completion (or it'd be done that
 > way already!)

I guess, I was approaching the problem from the wrong side.
What I am really interested in are the implications of this
fact for the programmer. What I believe to have understood
so far is:

  You have no guarantee that a finalizer you registered
  will ever be run -- even if the program terminates
  normally.

Is that correct? Or did I misunderstand something?

Peter

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


Re: Bug in touchForeignPtr?

2004-11-23 Thread Peter Simons
Simon Marlow writes:

 >>> Note that the GC only starts the finaliser thread. The
 >>> program can still terminate before this thread has run
 >>> to completion [...]

 > If you want anything else, you can implement it.

How do I implement that particular feature? I don't see how
I could write a 'main' function that waits for the finalizer
thread having terminated.

I really don't know much about the RTS internals, maybe an
URL is all I need?

Peter

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


Re: Marshall Multidimensional list, multidimensional array

2004-11-10 Thread Peter Simons
[EMAIL PROTECTED] writes:

 > To marshall a [[Int]] ...

 >  withArray2D xs f = withArray (concat xs) f

 >  withArray2D xs f = withArray xs' f
 >  where   xs' = concat $ map (take dim) xs
 >  dim = minimum $ map length xs

Um, I really wouldn't use the term "marshaling" when talking
about these functions because in the general case the result
of the first one will crash your process and the second one
loses data.

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


Re: Marshall Multidimensional list, multidimensional array

2004-11-10 Thread Peter Simons
David Lo writes:

 > [[Int]] to int[][]

Pardon me if I'm telling you something you already know, but I
wanted to make sure you are aware of it.

int[][] is a very different type than [[Int]] is. An int[][]
is a pointer to an array of pointers to integers:

 int[][]  <==>  int*[]  <==>  int**

Now think of the following Haskell list:

 [ [ 1, 2, 3, 4]
 , [ 1 ]
 , [ 1, 2 ]
 ]

C can't easily express that because an array in C does not
have a length -- a list in Haskell, however, does. To
understand the difference, just ask yourself what the element
my_list[1][3] would be. In the Haskell type, this element does
not exist: The second list has only one element. Only, C
doesn't know that! It will simply translate the expression to:

  *( *(my_list + 1) + 3 )

And give you the contents of any random memory location, thus,
almost certainly crashing your program. Which is why C sucks
and Haskell rules. :-)

My point is: marshaling a nested list is really not as simple
as it looks and int[][] is almost certainly not the right type
to marshal to. You'd need something that contains the
information which element list is how long, something like:

  struct integer_list
{
size_t  len;
int*elements;
}

  struct nested_list
{
size_t len;
integer_list*  elements
}

What _exactly_ you would need, though, is impossible to say
without understanding what you are trying to do. And
explaining all this would probably be too complex to do it
casually on a public mailing list.

I hope this helps somewhat. And I hope I remembered the order
in which C does resolve the int[][] type correctly. I could
never get that right. I hope someone corrects me, should it be
wrong.

Peter

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


Re: Export through FFI Haskell List to C array (by MarshalAlloc)

2004-11-09 Thread Peter Simons
David Lo writes:

 > Anyone has ever tried exporting Haskell list to C array?

Check out the module Foreign.Marshal.Array, specifically the
functions:

  withArray:: Storable a => [a] -> (Ptr a -> IO b) -> IO b
  withArrayLen :: Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b

These will marshal a Haskell list into a C array and hand
the pointer to the given function. Because the array is gone
when your function returns, you don't need to worry about
freeing resources, catching exceptions, etc. If you need
more fine-grained control, you'll find the module also has
functions equivalent to the usual malloc/free way of doing
things.

Peter

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


Re: getUserEntryForName weirdness

2004-11-06 Thread Peter Simons
Volker Stolz writes:

 > Fixed in CVS

I've tried it moments ago: Works correctly here, too, now.
Thank you.

Peter

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


Re: CVS build failure

2004-11-05 Thread Peter Simons
The problem turned out to a Gentoo bug. :-(

It can be fixed by executing 

  ACCEPT_KEYWORDS=~x86 emerge libxslt 

which upgrades to version 1.1.9-r1. With that, I can build
GHC again.

Sorry about the "misreport". 

Peter

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


Re: CVS build failure (was: Building the add-ons in libraries/...)

2004-11-05 Thread Peter Simons
And some more information on the issue. When I run the
configure script, I see this error message on the screen
(which probably won't make it into the config.log output):

 | checking for xmllint... /usr/bin/xmllint
 | checking for DocBook DTD... ok
 | checking for xsltproc... /usr/bin/xsltproc
 | checking for DocBook XSL stylesheet directory...
 |  ./configure: line 4557: 22276 Segmentation fault
 |  $XsltprocCmd ${fp_var}/html/docbook.xsl conftest.xml
 |  >/dev/null 2>&1
 | no
 | configure: WARNING: cannot find DocBook XSL stylesheets,
 |  you will not be able to build the documentation

The xsl stylesheets are installed at

  /usr/share/sgml/docbook/xsl-stylesheets-1.65.1/

on my machine, so configure _should_ find them.

Peter

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


CVS build failure (was: Building the add-ons in libraries/...)

2004-11-05 Thread Peter Simons
Sven Panne writes:

 >> /html/chunk.xsl happy.xml
 >> warning: failed to load external entity "/html/chunk.xsl"

 > It looks like configure hasn't found a DocBook XSL
 > directory on your machine. Could you provide us with a
 > little bit more information, please (log of the configure
 > run, config.log, platform, ...)?

Linux x86, I configure my build with the script:

 | #! /bin/sh --
 |
 | GHC="ghc-6.2.2"
 | SUBDIRS="alex ghc haddock happy hslibs libraries"
 |
 | for n in ${SUBDIRS} .; do
 |   echo >$n/mk/build.mk "XMLDocWays := html"
 | done
 |
 | autoreconf -i
 | ./configure --prefix=/usr/local/ghc-current \
 |   --enable-src-tree-happy   \
 |   --enable-src-tree-haddock \
 |   --enable-src-tree-alex\
 |   --with-ghc="${GHC}"   \
 |   --with-hc="${GHC}"\
 |   --enable-hopengl  \
 |   --disable-openal  \
 |   ;

and the "config.log" (266KB) file is available here:

  http://peti.cryp.to/config.log

You'll see some strange flags I pass to the C compiler when
using GHC. These are to disable SSP/PIE stack protection
code. Just ignore them. :-)

Hope this helps.

Peter

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


Building the add-ons in libraries/...

2004-11-02 Thread Peter Simons
The CVS version of the libraries tree comes with all kinds
of neat and dangerously unstable code I'd like to use,
particularly the "arrows" subdirectory. Now I wonder: Is
there some "build.mk" magic I could perform to tell GHC to
build these libraries as part of my normal build? So that I
get them (and the documentation) installed automatically
when I rebuild GHC?

Peter


P. S.: And while I am at it ... the build currently fails
with this error on my machine:

  ==fptools== make all -wr;
   in /usr/local/src/ghc-current/happy/doc
  
  rm -f -rf happy/
  /usr/bin/xsltproc --stringparam base.dir happy/ \
  --stringparam use.id.as.filename 1 \
  --stringparam html.stylesheet fptools.css \
  --stringparam toc.section.depth 3 --stringparam section.autolabel 1 \
  --stringparam section.label.includes.component.label 1   \
  /html/chunk.xsl happy.xml
  warning: failed to load external entity "/html/chunk.xsl"
  cannot parse /html/chunk.xsl
  make[2]: *** [happy/index.html] Error 4
  make[1]: *** [all] Error 1
  make[1]: Leaving directory `/usr/local/src/ghc-current/happy'
  make: *** [/usr/local/src/ghc-current/happy/src/happy-inplace] Error 2
  make: *** Deleting file `/usr/local/src/ghc-current/happy/src/happy-inplace'

Looks like there is a definition path missing somewhere.

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


Re: getUserEntryForName weirdness

2004-10-30 Thread Peter Simons
Peter Simons writes:

 >   getUserEntryForName [] >>= print . userName
 >   "wasabi"

I've updated the latest CVS HEAD (you never know) and tried
it again. Some problem.

In case it helps:

  http://peti.cryp.to/strace-getuserentry  (8kb)

Peter

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


Re: Is it safe to call getProcessExitCode more than once?

2004-10-30 Thread Peter Simons
Glynn Clements writes:

 > Although, depending upon the OS, setting SIGCHLD to
 > SIG_IGN may cause processes to be reaped automatically
 > (i.e. not become zombies), so that's a possible
 > alternative.

I think I've got it under control now. I'm using this
wrapper to make sure there are no unwaited-for child
processes:

  type ExternHandle = MVar (Handle, Handle, Handle, ProcessHandle)

  -- |Run an external process and store its handle in an
  -- 'MVar' with a finalizer attached to it that will close
  -- the handles and kill the process when the MVar falls out
  -- of scope.

  extern :: FilePath -> [String] -> IO ExternHandle
  extern path args = do
r <- runInteractiveProcess path args (Just "/") (Just [])
mv <- newMVar r
addMVarFinalizer mv (catch (cleanup r) (const (return (
return mv
  where
  cleanup (hin, hout, herr, pid) = do
terminateProcess pid >> safeWaitForProcess pid
hClose hin >> hClose hout >> hClose herr
return ()

  -- |Wait 10 seconds max. If the process hasn't terminated by
  -- then, throw an exception. If the child process has been
  -- terminated by a signal, return @ExitFailure [EMAIL PROTECTED] This is
  -- a kludge. So it will probably be in here forever.

  safeWaitForProcess :: ProcessHandle -> IO ExitCode
  safeWaitForProcess pid =
timeout maxwait loop >>= maybe badluck return
  where
  loop= catch loop' (\_ -> return (ExitFailure 137))
  loop'   = wait >> getProcessExitCode pid >>= maybe loop' return
  wait= threadDelay 100 -- 1/10 second
  maxwait = 1000-- 10 seconds
  badluck = fail "timeout while waiting for external process"

It's ugly, but it seems to work.

Peter

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


Re: runInteractiveProcess is broken

2004-10-30 Thread Peter Simons
Simon Marlow writes:

 >> test1 :: IO ()
 >> test1 = do
 >>   (_,_,_, pid) <- runInteractiveProcess "/usr/bin/sleep"
 >> ["3"] Nothing Nothing
 >>   sleep 1
 >>   rc <- waitForProcess pid
 >>   print rc

 > I can't repeat this, it works here:
 > *Main> test1
 > ExitSuccess
 > *Main> test2
 > Just ExitSuccess

 > Maybe run it through strace and send us the output?

I cannot reproduce the error myself anymore! I have no idea
what has changed; suddenly 'test1' and 'test2' both work
reliably -- whether I catch sigCHLD or not. It used to work
only when I did catch the signal. This is really bizarre.

The moment I see some strange behavior from these functions
again, I'll strace it right away and will come back to the
topic. Let's hope it never happens.

Thanks for the support everybody!

Peter

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


Syntax error in happy/doc/happy.xml

2004-10-30 Thread Peter Simons
Index: happy/doc/happy.xml
===
RCS file: /cvs/fptools/happy/doc/happy.xml,v
retrieving revision 1.7
diff -b -u -r1.7 happy.xml
--- happy/doc/happy.xml 29 Oct 2004 08:26:53 -  1.7
+++ happy/doc/happy.xml 30 Oct 2004 12:18:32 -
@@ -1777,11 +1777,11 @@
   
   There is some support for monadic parsers.
   The "tree decoding" mode 
-  (see ) can use the
+  (see ) can use the
   information given in the %monad 
   declaration to monadify the decoding process. 
   This is explained in more detail at
-  .
+  .
   
 
   

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


getUserEntryForName weirdness

2004-10-29 Thread Peter Simons
Is anyone else seeing this on his system?

  getUserEntryForName [] >>= print . userName
  "wasabi"

"wasabi" happens to be the last entry in the /etc/passwd
file, and that is what I get every time I query for an user
that doesn't exist. The source code promises an exception,
but I don't get one. 

Peter

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


Re: Is it safe to call getProcessExitCode more than once?

2004-10-27 Thread Peter Simons
Glynn Clements writes:

 > Both [waitForProcess and getProcessExitCode] will throw
 > an exception if the process terminated on a signal.

So if I terminate a process manually, I'll have to wait for
the ExitCode to avoid a zombie process, and waiting for the
ExitCode invariably throws an exception.

Or do I misunderstand something?

Peter

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


Re: runInteractiveProcess is broken

2004-10-26 Thread Peter Simons
I managed to get runInteractiveProcess to work after all.
Here is the code:

> import System.Posix.Signals
> import System.IO hiding ( catch, try )
> import System.Exit ( ExitCode(..) )
> import System.Process
> import Control.Concurrent
> import Child   -- http://cryp.to/child/Child.hs
>
> test :: IO ()
> test = do
>   installHandler sigCHLD (Catch (return ())) Nothing
>   (_,_,_, pid) <- runInteractiveProcess "/usr/bin/sleep" ["1"] Nothing Nothing
>   sleep 5
>   safeGetExitCode pid >>= print
>
> safeGetExitCode :: ProcessHandle -> IO ExitCode
> safeGetExitCode pid =
>   timeout (10*100) (getRCLoop) >>=
>   maybe (fail "timeout while waiting for external process") return
> where
> getRCLoop = getProcessExitCode pid >>=
> maybe (sleep 1 >> getRCLoop) return

The culprit seems to be: If you don't accept sigCHLD, you
lose. If you use waitForProcess, you lose. Threaded RTS or
not doesn't seem to make a difference.

Peter

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


runInteractiveProcess is broken

2004-10-26 Thread Peter Simons
Neither of these functions returns the return code of the
external process as promised:

  import System.IO hiding ( catch, try )
  import System.Process
  import Control.Concurrent

  sleep :: Int -> IO ()
  sleep n = threadDelay (abs(n) * 100)

  test1 :: IO ()
  test1 = do
(_,_,_, pid) <- runInteractiveProcess "/usr/bin/sleep" ["1"] Nothing Nothing
sleep 5
rc <- waitForProcess pid
print rc

  -- *Main> test1
  -- *** Exception: waitForProcess: does not exist (No child processes)

  test2 :: IO ()
  test2 = do
(_,_,_, pid) <- runInteractiveProcess "/usr/bin/sleep" ["1"] Nothing Nothing
sleep 5
rc <- getProcessExitCode pid
print rc

  -- *Main> test2
  -- Nothing

I'm using the ghc from CVS-HEAD on Linux/x86.

Peter

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


Re: Is it safe to call getProcessExitCode more than once?

2004-10-26 Thread Peter Simons
John Goerzen writes:

 > Assuming it is based on wait() or one of its derivatives,
 > and I suspect it is, you cannot call it more than once
 > for a single process.

That's what I _assume_, too, but a definite answer would be
nice. 

In the meanwhile, I have found out that it might not be safe
to call it once, even:

  CaughtException waitForProcess: does not exist (No child processes)

That's a child I _did_ start and which apparently terminated
before I called waitForProcess. Shouldn't I be getting the
exit code of that process rather than an exception?

Do waitForProcess and getProcessExitCode differ in their
behavior other than that one blocks and other doesn't?

Peter

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


Is it safe to call getProcessExitCode more than once?

2004-10-25 Thread Peter Simons
What will happen if I call getProcessExitCode for the same
process twice? Will that block? Cause an error? Or return
the same child's exit code again?

I assume the function is (under Unix) based on wait(2),
right? In that case, how does the following warning from the
manual page translate to Haskell?

  ERRORS
   ECHILD if the process specified in pid does not exist
  or is not a child of the calling process.
  (This can happen for one's own child if the
  action for SIGCHLD is set to SIG_IGN. See also
  the LINUX NOTES section about threads.)

The reason I am asking is because I want to avoid zombie
processes by doing a "catch-all" getProcessExitCode for
every process I spawn through a finalizer. I'd just like to
know whether it's safe before I do it. :-)

Peter

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


Re: Are handles closed automatically when they fall out of scope?

2004-10-25 Thread Peter Simons
John Goerzen writes:

 > Now, if [I read with hGetContents h], then the first read
 > I try to make using it works, but subsequent ones don't,
 > since the first one made it half-closed already.

Maybe I misunderstood something ... but why do you need to
read from the stream multiple times after calling
hGetContents? The function returns the _entire_ (lazily
evaluated) input stream, there is no need to read again. You
already _have_ everything.

Peter

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


Re: Are handles closed automatically when they fall out of scope?

2004-10-25 Thread Peter Simons
Simon Marlow writes:

 > BTW, I assume you have a good reason for wanting to call
 > terminateProcess

Yes, I have to abort the process in case of an exception in
my code. Just giving it EOF is not enough, unfortunately.

Thanks a lot for taking the time to answer, Simon. I really
appreciate it.

Peter


P. S.: It might be worth adding a few sentences to the
description of 'Handle' which explain these problems. I'm
certain other users of the language will run into the same
questions.

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


Are handles closed automatically when they fall out of scope?

2004-10-22 Thread Peter Simons
I know it's a rather mundane question, but I couldn't find
an answer to it!

So what does happen when I forget to hClose a Handle? Will
the garbage collector do that for me? Or not?

And more specifically, what about the handles
runInteractiveProcess returns? Do I have to close the
"stdin" Handle? All of them? What happens when I use
terminateProcess? Do I have to hClose them nonetheless?

And while I am at it: How about Socket? Do I have to sClose
a socket I obtained from listenOn or accept?

Any definite answers would be highly appreciated. 

Peter

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


Re: CVS HEAD ghc fails with "Panic!"

2004-10-21 Thread Peter Simons
Simon,

I had answered to your e-mail almost two days ago, then I
resent my reply today, but apparently my e-mail doesn't
reach you! I see that it was delivered correctly here on my
machine:

  Oct 21 18:56:51 peti sm-mta[11337]: i9LGunqM011335:
  to=<[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>,
  ctladdr=<[EMAIL PROTECTED]> (1000/100), delay=00:00:02,
  xdelay=00:00:02, mailer=esmtp, pri=61578,
  relay=mailc.microsoft.com. [207.46.121.52], dsn=2.0.0,
  stat=Sent ( <[EMAIL PROTECTED]> Queued mail
  for delivery)

Maybe the Microsoft mail server doesn't like me? Anyway,
here is the URL you needed to check the bug report:

  http://cryp.to/hsemail/hsemail-2004-10-12.tar.gz

Peter

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


Re: ghc from CVS HEAD doesn't work with "-O -threaded"

2004-10-20 Thread Peter Simons
Simon Marlow writes:

 >> $ ghc -threaded -Wall -O --make test.hs -o test -ladns

 > Should be fixed now.

Just updated to the new version and tried it: The error is
gone. Thank you very much.

Peter

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


CVS HEAD ghc fails with "Panic!"

2004-10-20 Thread Peter Simons
Hi,

the GHC version from the current CVS HEAD aborts with an
internal error when doing this:

 $ darcs get http://cryp.to/hsemail
 $ cd hsemail
 $ ghc -O2 --make -o message-test message-test.hs
 | Chasing modules from: message-test.hs
 | Compiling Rfc2234  ( ./Rfc2234.hs, ./Rfc2234.o )
 | ghc-6.3: panic! (the `impossible' happened, GHC version 6.3):
 | app_match: unbound tpl c{tv a1a9}

Compiling with -O instead of -O2 works, though.

Peter

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


ghc from CVS HEAD doesn't work with "-O -threaded"

2004-10-19 Thread Peter Simons
The following reproducibly fails:

  $ darcs get http://cryp.to/hsdns  [*]
  $ cd hsdns/
  $ hsc2hs ADNS.hsc
  $ ghc -threaded -Wall -O --make test.hs -o test -ladns
  | Chasing modules from: test.hs
  | Compiling ADNS ( ./ADNS.hs, ./ADNS.o )
  | /tmp/ghc2613.hc:9:23: ADNS_stub.h: No such file or directory
  | /tmp/ghc2613.hc: In function `s8Xa_ret':
  | /tmp/ghc2613.hc:6340: error: `ADNS_d7eN' undeclared (...)

If you build the program without optimization,

  $ ghc -threaded --make test -ladns

it works just fine. This seems to happen only when the
threaded RTS in involved, -O without -threaded works.

Peter

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


Re: -ddump-minimal-imports and -hidir / -odir

2004-10-14 Thread Peter Simons
Simon Marlow writes:

 > A quick test doesn't show up anything obviously wrong.
 > Can you give more details?

It turned out the cause of the problem was a bug in my
Makefile, not in GHC. I am sorry about that, I should have
tested more before posting anything. I apologize.

Peter

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


Re: Performance-loss of accessing data through class?

2004-10-14 Thread Peter Simons
Simon Marlow writes:

 >>> class KnowsMyStuff a where
 >>> foo :: a -> Int
 >>> bar :: a -> Float
 >>> etc :: a -> [String]
 >>
 >> If I did that, how much performance would I lose?

 > If your code is using a method from a known instance of a
 > class, and the method has a small enough definition, then
 > chances are good that it'll get inlined and the extra
 > layer of abstraction will dissappear. I'm guessing this
 > is the case with your example.

Great, that's good to hear.


 > We always enjoy investigating benchmarks, so if you have
 > some code you think isn't going fast enough, then post it
 > here and we'll help you find out where the performance
 > problems are.

Alright, thanks for the offer. I'll certainly do that when I
notice anything. So far, I am pleased to say that the
performance is better than I had expected, actually. That
doesn't happen very often. :-)

Peter

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


-ddump-minimal-imports and -hidir / -odir

2004-10-12 Thread Peter Simons
Hi,

is it possible that GHC doesn't process the -hidir and -odir
command-line options correctly when -ddump-minimal-imports
is given as well? I have had this problem right now and
removing the -(hi|o)dir flags fixed it, so I figured I'd
better say something. ;-)

Peter

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


Re: HEAD version hsc2hs malfunction

2004-10-11 Thread Peter Simons
I cvs-updated my copy moments ago, but I still get this
error when compiling my ADNS.hsc bindings with the new
version:

 > /tmp/ghc12865.hc: In function `s8Ej_ret':
 > /tmp/ghc12865.hc:6355: error: `ADNS_d7gS' undeclared (first use in this function)
 > /tmp/ghc12865.hc:6355: error: (Each undeclared identifier is reported only once
 > /tmp/ghc12865.hc:6355: error: for each function it appears in.)

I have no idea whether hsc2hs or the compiler itself is the
problem; does, by any chance, anyone know (or can give me a
hint) how to fix this?

Peter

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


Performance-loss of accessing data through class?

2004-10-09 Thread Peter Simons
Hi,

in a module I am writing, I am using a 'StateT st IO' monad
with a state like this:

  data MyState st = ST !Int !st

My own monad is yet-another wrapper for ... another state
monad. And that's getting inconvenient.

So I wondered whether it would be good to define a class
that unified all those StateTs into _one_ state, like:

> class KnowsMyStuff a where
>   foo :: a -> Int
>   bar :: a -> Float
>   etc :: a -> [String]

Then I could write my functions so that they'd work on any
MonadIO which has some way of getting those instances
defined.

If I did that, how much performance would I lose? Accessing
those values would probably require one more level of
indirection, that can't be as fast as having a specific data
type, right?

Or is there some optimizer magic at work here?

Peter


P. S.: Right now the code is _very_ fast, and I'd rather
have that than an convenient interface, that's why I ask.

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


HEAD version hsc2hs malfunction

2004-10-08 Thread Peter Simons
I have problems with the current HEAD version when compiling
my ADNS bindings . It appears
that ghc has stopped passing the correct search path
automatically, because with the new version I had to add an
explicit "-I/home/simons/projects/foo" when compiling, or it
wouldn't find the _stub.(c|h) files. Once I had that sorted
out, I got this:

  /tmp/ghc12865.hc: In function `s8Ej_ret':
  /tmp/ghc12865.hc:6355: error: `ADNS_d7gS' undeclared (first use in this function)
  /tmp/ghc12865.hc:6355: error: (Each undeclared identifier is reported only once
  /tmp/ghc12865.hc:6355: error: for each function it appears in.)

Is this a bug in the compiler? In hsc2hs? My fault? 

Peter

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


Re: threadsafe needed

2004-10-05 Thread Peter Simons
John Meacham writes:

 > in particular system, rawSystem, and DNS lookups are
 > important to be able to do concurrently.

For DNS, there is a solution available here:

  http://cryp.to/hsdns/

Peter

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


Re: reading text files

2004-10-04 Thread Peter Simons
Carsten Schultz writes:

 > I want to read a text file from a socket and process it as a String
 > (using Parsec).  Is hGetContent ok, or are there mor efficient
 > alternatives available, even if I want a String anyway?

hGetContents is fine, although you have to be aware that the
function does not implement any timeouts. Meaning, if you
don't receive the data you need, your program will hang.

Whether your application is fast or not doesn't really
depend on how you read the data, but on how you _process_
it. Personally, I've always tried to stay away from
hGetContents and friends, because once you have the "whole"
list at your disposal, the temptation is huge to write code
that treats the data as if you _had_ it all in memory, and
that usually is very inefficient. I'd rather read the input
in blocks, or lines, and process it as such.

Peter

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


hWaitForInput and timeouts

2004-10-03 Thread Peter Simons
Hi,

I have another I/O problem. I need to time out when a Handle
blocks forever. I am using hWaitForInput anyway, so that
shouldn't be a problem, but the documentation says that
using this feature will block all IO threads? Is it much
work to fix this? I _could_ forkIO a racer thread myself, of
course, but it feels wrong to do that around a function that
has an explicit timeout argument. :-)

Peter

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


Re: Is there a non-blocking version of hGetArray?

2004-10-02 Thread Peter Simons
Simon Marlow writes:

 > I'm surprised if pointer access to memory is slower
 > than unsafeRead.

You were right. Now that I have made some tests, the
problem turned out to be elsewhere. Pointer access is
not to blame. ;-)

Peter

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


Re: Is there a non-blocking version of hGetArray?

2004-10-01 Thread Peter Simons
Simon Marlow writes:

 > Not currently, but I could probably implement the
 > equivalent (hGetArrayNonBlocking).

If that were possible, I'd greatly appreciate it.


 > I'm surprised if pointer access to memory is slower than
 > unsafeRead. Could you post some code that we can peer at?

Not right now, sorry. It's just a suspicion I have, but I
haven't broken down the functions enough to be certain (or
to post an isolated test case). But I will look at this
further and let you know about it, once I have more
"evidence". :-)

Thanks for helping, Simon.

Peter

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


Is there a non-blocking version of hGetArray?

2004-10-01 Thread Peter Simons
Hi,

I am a happy user of hGetBufNonBlocking, but I have come to
realize that mutable arrays are nicer to work with than
pointers, so I have considered using hGetArray instead. I
do, however, depend on the fact that the function returns as
soon as it has read data -- even if less than requested --,
like hGetBufNonBlocking does.

Is there currently a way to achieve this?

Am I right assuming that hGetBuf and hGetArray do not differ
much performance-wise?

One of the reasons I am curious about using mutable arrays
is because of Data.Array.Base.unsafeRead, which seems to be
a *lot* faster than accessing the memory through a pointer.
Is there anything comparable for pointer access?

Peter

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


Re: Haddock: how to disable the JavaScript menus?

2004-09-28 Thread Peter Simons
Simon Marlow writes:

 > The tree is expanded by default now (Sven Panne made the
 > change a few days ago).

I have rebuilt everything from CVS HEAD moments ago and the
generated reference documentation still comes with the menus
collapsed. Am I doing something wrong?

Peter

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


Re: Haddock: how to disable the JavaScript menus?

2004-09-28 Thread Peter Simons
While I am at it: There is another (rather simple) feature
I'd like to see in Haddock. I often link to
Haddock-generated documentation on my web pages, but there
is no way for me to link _back_ from the Haddock output.

Would it be possible to add command line switch to specify
an "up" link and the appropriate text for it, which would
appear next to the "Contents" and "Index" links?

Something like "--top http://cryp.to/,Homepage"; or so?

Peter

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


Re: Haddock: how to disable the JavaScript menus?

2004-09-27 Thread Peter Simons
Simon Marlow writes:

 > This change has now been made.  

Uh ... any hints what has changed? A new command line flag? 


 > we need a way to retain the collapsed/expanded state
 > between page transitions (JavaScript hackers apply
 > here!).

I am not certain whether these collapsed menus are a good
idea. Admitted, they make the page shorter at first glance.
But at the same time, they make it impossible to search in
the text! 

When I want to see the documentation for, say Data.List, I
hit CTRL-HOME in Mozilla, then type "/data.lis", and finally
press RETURN to follow the link -- and I have reached the
page. The hands never left the keyboard. With collapsed
menus, that doesn't work anymore. 

Anyway, if there was an option to enable/disable that
functionality in Haddock, all would be well. :-)

Peter

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


newCString -- to 'free' or not?

2004-09-25 Thread Peter Simons
When I create a CString with Foreign.C.String.newCString, do
I have to 'free' it after I don't need it anymore? Or is
there some RTS magic taking place?

How about Foreign.Marshal.Utils.new and all those other
newXYZ functions? 

Peter

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


Re: Release candidate for 6.2.2 availabe

2004-09-23 Thread Peter Simons
Sven Panne writes:

 >> 1) The build fails:

 > My fault, already fixed.

Great. Just built the compiler from the scratch; works
nicely now.


 >> 2) "make distclean" fails:

 > I'll have a look into it.

Also works correctly now. 


 > make XMLDocWays="html ps" install-docs

OK. :-) I changed SGMLDocWays to XMLDocWays in the build.mk
files and now everything works as expected again.


 > Furthermore, with our current build system there is no
 > need for a build.mk anymore IMHO.

I think it's nice to have a way to configure the build
"permamently" so that I can just forget about it and say
"make install", "make install-docs", etc., with all the
proper flags being passed automatically. It's hard to
remember which packages needs what additional settings, so I
am quite fond of the build.mk files.

Thanks for your help, Sven.

Peter

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


Re: Release candidate for 6.2.2 availabe

2004-09-20 Thread Peter Simons
I have some trouble building ghc from CVS HEAD. I'm not sure
whether this applies to the release candidate version, too,
but I figured I'd better report it anyway, just in case.

 1) The build fails:

 | ../../ghc/compiler/ghc-inplace -M -optdep-f -optdep.depend
 |   -optdep-s -optdepp -osuf o-H16m -O -optc-fno-pic
 |   -optc-fno-stack-protector -fglasgow-exts -cpp -Iinclude
 |   -"#include" HsBase.h -funbox-strict-fields -package-name
 |   base -O -Rghc-timing Control/Arrow.hs Control/Concurrent.hs
 |   Control/Concurrent/Chan.hs [...]
 | Data/FiniteMap.hs:111: token "@" is not valid in preprocessor expressions
 | Data/FiniteMap.hs:314: token "@" is not valid in preprocessor expressions
 | Data/FiniteMap.hs:420: token "@" is not valid in preprocessor expressions
 | Data/FiniteMap.hs:584: token "@" is not valid in preprocessor expressions
 | Data/FiniteMap.hs:733: token "@" is not valid in preprocessor expressions
 | Data/FiniteMap.hs:746: token "@" is not valid in preprocessor expressions
 | Data/FiniteMap.hs:807: token "@" is not valid in preprocessor expressions
 | <>
 | make[2]: *** [depend] Error 1
 | make[1]: *** [boot] Error 1
 | make[1]: Leaving directory `/usr/local/src/ghc-current/libraries'


 2) "make distclean" fails:

 | $ make distclean
 | rm -f -rf autom4te.cache
 | rm -f *.CKP *.ln *.BAK *.bak [...]
 | 
 | ===fptools== Recursively making `distclean' in glafp-utils happy alex haddock ghc 
libraries hslibs docs ...
 | PWD = /usr/local/src/ghc-current
 | 
 | 
 | ==fptools== make distclean -r;
 |  in /usr/local/src/ghc-current/glafp-utils
 | 
 | You haven't run ./../configure yet.
 | make[1]: *** [../config.status] Error 1
 | make: *** [distclean] Error 1


 3) In order to build GHC's user manual and the
documentation for the older libraries, I use the following
bit of shell scripting before I run configure:

 | DOCDIRS="alex ghc haddock happy hslibs libraries"
 | 
 | for n in ${DOCDIRS}; do
 |   echo >$n/mk/build.mk "SGMLDocWays := html"
 | done
 | 
 | echo  >mk/build.mk "SGMLDocWays := html"

But apparently, this has stopped working! A "make
install-docs" will neither install nor even build the
documentation. (I have had this problem for a few weeks, but
never really came around to investigate it.)

Peter

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


Re: GHC CVS build...

2004-08-13 Thread Peter Simons
K P SCHUPKE writes:

 > fptools/mk/config.h.in

 > seems to be missing and nothing can be built.

Run "autoreconf -i" in the checked-out copy of the
repository to generate the dependent files.

Peter

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


"Stricts _"

2004-07-13 Thread Peter Simons
ghci-6.3 (from CVS) shows me strictness information when I
request :info for a data type, like:

[...] Send Mailbox   Stricts: _ [...]

I have no idea how to read that output, and it doesn't seem
to be documented in the manual either. Does the underscore
signify that (in the example above) Mailbox is a strict
value? Or is it the opposite?

Sorry if this is a dumb question, but I simply don't know
it. :-)

Peter

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


Re: Socket Options

2004-06-28 Thread Peter Simons
K P SCHUPKE writes:

 > I believe a (unix) socket level problem (including remote
 > server closing the connection unexpectedly) results in a
 > Posix SigPIPE.

No, it's an ordinary failure in the read()/write()
operation. Quoting from socket(7):

 | SO_RCVTIMEO and SO_SNDTIMEO
 |Specify the receiving or sending timeouts until
 |reporting an error. The parameter is a struct timeval.
 |If an input or output function blocks for this period
 |of time, and data has been sent or received, the
 |return value of that function will be the amount of
 |data transferred; if no data has been transferred and
 |the timeout has been reached then -1 is returned with
 |errno set to EAGAIN or EWOULDBLOCK just as if the
 |socket was specified to be nonblocking. If the timeout
 |is set to zero (the default) then the operation will
 |never timeout.

Turns my earlier statement about setting errno to ETIMEDOUT
wasn't quite correct. :-)


 > Is you set the default action to ignore:

 >  installHandler sigPIPE Ignore Nothing

 > Then it gets converted to an asynchronous exception... 

I am not sure I understand this: If I say _Ignore_, then an
asynchronous exception will be thrown? Would the exception
tell me _which_ Socket had the error? It would be raised in
the main thread, right? How could I tell which Socket had
the timeout if I used more than one? 

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


Re: Socket Options

2004-06-28 Thread Peter Simons
Simon Marlow writes:

 > The runtime uses non-blocking I/O and select() internally
 > in order to support multi-threaded I/O. We don't have any
 > direct support for timeouts [...]

Thanks for the clarification. I understand that.

But what would happen if I _do_ set a timeout on the socket
level nonetheless? The timeout would strike in form of a
read() or write() call returning -1 with an errno of
ETIMEDOUT, so clearly it would be noticed by the RTS. The
question is: will the RTS report the failure to me through
an asynchronous exception?

Because if it does, then that is all the "support" I'll ever
need, it saves me from 'forkIO'ing a racer thread for every
operation that might time out.

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


Re: Socket Options

2004-06-28 Thread Peter Simons
Simon Marlow writes:

 > It doesn't say what happens to select() on a socket that
 > times out, so I'm not sure what will happen if you try
 > this in GHC.

Okay, thanks for the information! Looks like a racer thread
per timeout is the better approach after all.

Peter

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


Re: Socket Options

2004-06-28 Thread Peter Simons
Martin Sjögren writes:

 > Wouldn't that make
 >   getSocketOption :: Socket -> SocketOption -> IO Int
 > a bit strange? How would you propose to change it?

Right, that is a problem. My first idea how to fix this
would be

  getSocketOption :: Socket -> SocketOption -> IO SocketOption

as in:

  Debug v <- getSocketOption sock (Debug undefined)

But that's the first idea, not necessarily the best.

Peter

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


Re: Socket Options

2004-06-28 Thread Peter Simons
Glynn Clements writes:

 >> Am I even supposed to set them, or is there a better way to
 >> specify general I/O timeouts than on the socket level?

 > Non-blocking I/O and select/poll; although I don't know
 > how well that is supported.

Can anyone tell me how well supported it is? What would
happen if a timeout occurs in the _socket_ level? Will an
exception be thrown? Can I count on this behavior even when
reading from a socket (read: a Handle promoted from a
Socket) with hGetContents?

Peter

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


Re: Socket Options

2004-06-28 Thread Peter Simons
Simon Marlow writes:

 > I'm tempted to replace the current setSocketOption with
 > this version. Would anyone object?

On the contrary. IMHO, the SockOption type should be
extended to contain the required parameter, for example:

  data SocketOption
  = Debug Bool
  | ReuseAddr Bool
  | SendBuffer (Maybe Int)   -- bytes
  | RecvTimeOut (Maybe Int)  -- milliseconds
  | SendTimeOut (Maybe Int)
  | [...]

Then setSocketOption would even add the type-safety which
the original function call doesn't have, and it would be
more intuitive to use.

Peter

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


Socket Options

2004-06-25 Thread Peter Simons
Hi,

the Network module provides the data type SocketOption. I am
particularly interested in setting the RecvTimeOut and
SendTimeOut values, but I wonder how to set them. The
function

  setSocketOption :: Socket -> SocketOption -> Int -> IO ()

allows me only 'Int' parameters, but the kernel expects a
struct timeval here -- or more accurately, a pointer to one.
Do I really have to engage in FFI pointer wizardry here, or
is there a simpler way to set these values?

Am I even supposed to set them, or is there a better way to
specify general I/O timeouts than on the socket level?

Peter

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


Re: optimization question

2004-02-23 Thread Peter Simons
Max Kirillov writes:

 >> [...] I will generate large case statements like the
 >> first form and want to know if I should bother
 >> pre-optimizing it to the second.

 > I suppose such things should be made by flex-style
 > generators. 

If you don't mind using FFI, the tool of choice would
probably be .

Peter

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


Re: Problem with using BNF converter tool

2004-02-16 Thread Peter Simons
robin abraham writes:

 > happy.bin: internal error: stg_ap_pp_ret
 > Please report this as a bug to [EMAIL PROTECTED],
 > or http://www.sourceforge.net/projects/ghc/

Which versions of BNFC, happy, and alex do you use?

Does BNFC get through a "make frontend"? Can it correctly
re-generate itself?

Peter

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


Non-exhaustive patterns in basicTypes/Var.lhs

2004-01-18 Thread Peter Simons
QuickCheck's 'generate' function works fine in GHCi, but
only for the _first_ time I call it. After that, I get an
error:

 | Ok, modules loaded: Main.
 | *Main> generate 3 (mkStdGen 28) (return 'x')
 | Loading package QuickCheck ... linking ... done.
 | 'x'
 |
 | *Main> generate 3 (mkStdGen 28) (return 'x')
 | *** Exception: basicTypes/Var.lhs:226:32-58: Non-exhaustive
 | patterns in record update

Peter

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


File permissions of /tmp files

2003-10-28 Thread Peter Simons
Hi,

it appears that ghc (and ghci) create temporary files in
/tmp during the un-lit phase, at least. It would be nice, if
ghc would ...

 - create those files with read/write permission for the
   owner only, 0600.

 - set-up some atexit(3) job, or whatever, to make sure
   those files _are_ deleted when ghc exits.

It might even be possible to create the file and then
remove(3) it, right away. The file handle will continue to
work, but there is never an entry in the file system.

Just a suggestion. :-)

Peter

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


Re: Transmitting Haskell values

2003-10-28 Thread Peter Simons
Joachim Durchholz writes:

 > What sent me first into deep confusion is that I found all of
 > {Text,GHC}.{Read,Show} first, and the Read classes marked as
 > "nonportable GHC extensions".

Then you will surely love the Foreign.* hierarchy, most notably
Foreign.Storable. If you want to do binary I/O within "standard"
Haskell, this is the place to look at. I found [1] to be a pretty good
introduction to the subject.

Just for the sake of providing you with an alternative to read / show:
Take a look at HaXml [2]. This package provides means to read and
write Haskell data structures as XML files, what is about as platform
independent as you can get.

Peter


[1] http://www.cse.unsw.edu.au/~chak/haskell/ffi/
[2] http://www.cs.york.ac.uk/fp/HaXml/index.html

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


GHC and gcc 3.3.1

2003-10-20 Thread Peter Simons
Just curious: Has anyone successfully compiled GHC with gcc
3.3.1 on Linux/x86? I'm having trouble here with both GHC
6.0 and GHC-current. Is that just me?

Peter

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


Re: Haddock interface file for standard libraries

2003-09-23 Thread Peter Simons
Simon Marlow writes:

 > /usr/share/ghc-6.0.1/html/*/*.haddock.

Hmm, why is it that every question I asks resolves in a way that makes
me look blind or dumb? :-)

Thanks for the quick help!

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


Haddock interface file for standard libraries

2003-09-23 Thread Peter Simons
I have another short question concerning the build process: Is there
any easy way to generate a Haddock interface file for the standard
libraries? I'd like my own documentation to contain links to standard
data types and functions, but processing the library sources directly
turned out to be difficult because of pre-processor use etc.

Peter

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


Re: Installing _all_ documentation?

2003-09-22 Thread Peter Simons
Simon Marlow writes:

 > The same technique works for Happy, Haddock & Alex, except that
 > some of these (I forget which) didn't have the doc directory
 > included in the standard build, so you had to go into eg. happy/doc
 > and say 'make install-docs' explicitly.

Adding "SGMLDocWays := html" to each projects respective "mk/build.mk"
file builds the documentation just fine. Thanks for the help!

One more nit, though: "make install-docs" won't do anything in the
"haddock" and "happy" projects! For "alex", it works fine, but
installs the documentation to "${datadir}/html" whereas GHC installs
it documentation into "${datadir}/ghc-6.3/html", which seems to be
slightly inconsistent.

Peter

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


Re: Installing _all_ documentation?

2003-09-18 Thread Peter Simons
Ian Lynagh writes:

 > echo "SGMLDocWays   := html dvi ps" >> mk/build.mk

This works great! Is there any chance I can "extend" this technique so
that it will include the documentation of, say happy, haddock, and
alex as well?

Peter


P. S.: I'm sorry ... I guess I should really read the documentation of
   the fptools myself. :-)

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


Installing _all_ documentation?

2003-09-17 Thread Peter Simons
Pardon me if this is a dumb question, but is there a make target,
which I can use to install all documentation that comes with the
build? I am aware of "make install-docs", but this doesn't build nor
install, say, the user's guide. Nor does it install documentation for
Alex or Happy, even though I'm building those tools as part of GHC.

Any obvious solutions?

Peter

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


  1   2   >