Re: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Joel Reymont
No way. Thanks for the suggestion, though ;-). On Dec 12, 2005, at 7:48 AM, Tomasz Zielonka wrote: As a fast and dirty solution, I propose using MVar [Dynamic]. -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Joel Reymont
The app is multi-threaded but uses lightweight threads (unbound). On Dec 12, 2005, at 4:24 AM, Branimir Maksimovic wrote: If your app is single threaded you should be ok. But then nothing is executed concurrently? why locking at all then? You wouldn;t have problems with deadlocks and

[Haskell-cafe] Tricky exception handling

2005-12-12 Thread Joel Reymont
Folks, I have a thread that launches socket reader and writer threads. My intent is to notify the main thread when an exception is caught by the reader/writer. Is this code proper? --- withException :: (Event a - IO ()) - IO () - IO Bool withException post

Re: [Haskell-cafe] Substring replacements

2005-12-12 Thread Daniel Fischer
Am Montag, 12. Dezember 2005 01:34 schrieben Sie: On 12/12/05, Daniel Fischer [EMAIL PROTECTED] wrote: Okay, I have looked up KMP and implemented it. Seems to work -- my first use of QuickCheck, too. It's slower than Bulat's and Tomasz' for Branimir's test :-(, but really fast for my

Re: [Haskell-cafe] STM, orElse and timed read from a channel

2005-12-12 Thread Joel Reymont
While we are waiting for ghc 6.6, could the same effect be achieved by launching the computation that writes to t with forkIO? On Nov 29, 2005, at 12:00 PM, Simon Marlow wrote: threadDelay is IO-only; there's no way to use threadDelay in an STM transaction. For example, if you want to wait

Re: [Haskell-cafe] STM, orElse and timed read from a channel

2005-12-12 Thread Tomasz Zielonka
On Mon, Dec 12, 2005 at 10:08:56AM +, Joel Reymont wrote: While we are waiting for ghc 6.6, could the same effect be achieved by launching the computation that writes to t with forkIO? Yes, it was proposed before. Booo... nobody likes my TimeVar implementation... :-( Best regards Tomasz

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-12 Thread John Meacham
On Sun, Dec 11, 2005 at 07:41:43PM +, Ben Rudiak-Gould wrote: I think the problem is not with the use of forall, but with the use of the term existential type. The fact that existential quantification shows up in discussions of this language extension is a red herring. Even Haskell 98

Re: [Haskell-cafe] STM, orElse and timed read from a channel

2005-12-12 Thread Joel Reymont
If you are talking about the STM one then I saved it for later use. I'm not using timers at all now but it got to the point where I had about 3-5 different implementations stashed away. Yours is one of two remaining, Simon's being the second one :-). On Dec 12, 2005, at 10:09 AM, Tomasz

Re: [Haskell-cafe] STM commit hooks

2005-12-12 Thread Joel Reymont
I haven't seen a reply on this but would be really interested in one. Simon? On Nov 29, 2005, at 12:39 PM, Einar Karttunen wrote: Hello I have been playing with STM and want to log transactions to disk. Defining a logging function like: log h act = unsafeIOToSTM $ hPrint h act works most

Re: [Haskell-cafe] STM commit hooks

2005-12-12 Thread Joel Reymont
Missed this reply. My bad and apologies to Simon. Einar, did it work for you? On Dec 2, 2005, at 11:15 AM, Simon Marlow wrote: How about this: log_lock - newTMVar () atomically3 h act = do atomically (do act; takeTMVar log_lock `orElse` abort h) hPrint h Commit atomically

Re: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Branimir Maksimovic
From: Joel Reymont [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX Date: Mon, 12 Dec 2005 09:00:18 + The app is multi-threaded but uses lightweight threads (unbound). So that

Re: [Haskell-cafe] Opening the same file multiple times

2005-12-12 Thread Duncan Coutts
On Mon, 2005-12-12 at 07:43 +0200, Einar Karttunen wrote: Hello It seems that opening the same file multiple times (one writer and multiple readers) is not supported at least on *nix with GHC. I want to use one Handle to use append data till the end of the file while other Handles perform

Re: [Haskell-cafe] Substring replacements

2005-12-12 Thread Branimir Maksimovic
From: Daniel Fischer [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Mon, 12 Dec 2005 10:31:49 +0100 Am Montag, 12. Dezember 2005 01:34 schrieben Sie: On 12/12/05, Daniel Fischer [EMAIL PROTECTED] wrote: Okay, I

Re: [Haskell-cafe] Opening the same file multiple times

2005-12-12 Thread Einar Karttunen
On 12.12 12:06, Duncan Coutts wrote: It states in the Haskell Report 21.2.3: http://haskell.org/onlinereport/io.html Thanks, for the pointer, but am looking for an extension in the non-haskell98 API to do it. It seems that things are quite problematic: 1) Use openFile or GHC.Handle.openFd

Re[2]: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Bulat Ziganshin
Hello Branimir, Sunday, December 11, 2005, 9:43:08 PM, you wrote: BM After seeing this only I can tell that for example in C++ one can't cout BM clog cerr BM or post some event via synchronized event queue or condition variable BM from signal handler. BM All of that would result in ghosts and

Re: [Haskell-cafe] Opening the same file multiple times

2005-12-12 Thread Bulat Ziganshin
Hello Einar, Monday, December 12, 2005, 8:43:15 AM, you wrote: EK It seems that opening the same file multiple times (one writer EK and multiple readers) is not supported at least on *nix with EK GHC. I want to use one Handle to use append data till the EK end of the file while other Handles

Re[2]: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Bulat Ziganshin
Hello Branimir, Monday, December 12, 2005, 2:52:47 PM, you wrote: BM If GHC implements user space threads that would be great, BM but that does not helps with your problems. ghc (and any other haskell implememtations which implements Concurrent Haskell extensions) implement IT'S OWN threads.

[Haskell-cafe] RE: [Haskell] fptools mirror in darcs ready for testing

2005-12-12 Thread Simon Marlow
On 08 December 2005 18:21, Malcolm Wallace wrote: http://cvs.haskell.org/darcs/ghc http://cvs.haskell.org/darcs/libraries It suddenly occurs to me that there are other projects in CVS that have not yet been converted to darcs, e.g. Hugs98 and nhc98. Are there plans to do so? If not, then

Re: Re[2]: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Joel Reymont
I'm positively not catching the ^C in the main thread. I just went ahead and disabled ^C handling alltogether. On Dec 12, 2005, at 10:50 AM, Bulat Ziganshin wrote: but in 6.4.1 (ATTENTION, JOEL!) this code was breaked. i does an investigation and found that in 6.4.1 with -threaded ^Break

Re: [Haskell-cafe] Substring replacements

2005-12-12 Thread Daniel Fischer
Earlier today: Sorry, but Prelude SearchRep searchReplace abaaba ## abababaaba abababaaba I haven't analyzed the algorithm, so I don't know why exactly this fails. I'll take a look sometime soon. I found the problem (one at least). Say the pattern to be replaced begins with 'a' and we have

Re: [Haskell-cafe] Substring replacements

2005-12-12 Thread Branimir Maksimovic
From: Daniel Fischer [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Mon, 12 Dec 2005 13:07:29 +0100 Sorry, but Prelude SearchRep searchReplace abaaba ## abababaaba abababaaba I haven't

RE: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Simon Marlow
On 11 December 2005 17:19, Joel Reymont wrote: Nothing like answering your own questions... There's no deadlock information for the threaded version of the runtime so I would not have deadlock information if I were to compile with -threaded. This doesn't really help you right now, but

RE: [Haskell-cafe] Opening the same file multiple times

2005-12-12 Thread Simon Marlow
On 12 December 2005 14:01, Einar Karttunen wrote: On 12.12 12:06, Duncan Coutts wrote: It states in the Haskell Report 21.2.3: http://haskell.org/onlinereport/io.html Thanks, for the pointer, but am looking for an extension in the non-haskell98 API to do it. It seems that things are

Re: [Haskell-cafe] Substring replacements

2005-12-12 Thread Branimir Maksimovic
From: Daniel Fischer [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Mon, 12 Dec 2005 16:15:46 +0100 Earlier today: Sorry, but Prelude SearchRep searchReplace abaaba ## abababaaba abababaaba

[Haskell-cafe] Bringing Erlang to Haskell

2005-12-12 Thread Joel Reymont
Folks, I love the Erlang multi-processing experience and think that a lot of the mistakes that I made could be avoided. What I want to have is 1) Processes, aka threads with single-slot in/out mailboxes 2) A facility to keep a list of such processes and send events to them using their

Re[2]: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Bulat Ziganshin
Hello Branimir, Monday, December 12, 2005, 3:47:12 AM, you wrote: BM Perhaps you can implement this in Haskell? dedicate single thread to BM just handle ^C signal? this is how you should do it properly, BM but I would go with console client anyway: moreover, that must be the MAIN THREAD, as i

Re: [Haskell-cafe] Tricky exception handling

2005-12-12 Thread Bulat Ziganshin
Hello Joel, your code is unreadable, inefficent and don't handle async exceptions between calls to `handle`. as i already sayed you'd better to use: handle (...) repeat_forever do cmd - read h ssl post $! Cmd $! cmd Monday, December 12, 2005, 12:30:27 PM, you wrote: JR Folks,

Re[2]: [Haskell-cafe] Re: syscall, sigpause and EINTR on Mac OSX

2005-12-12 Thread Bulat Ziganshin
Hello Joel, this code really looks strange: you asks to create global veriable, but don't say its type :) polymorhism is for functions definitions, any concrete data in Haskell have concrete type Sunday, December 11, 2005, 11:37:06 PM, you wrote: JR Would you care to elaborate? This has not

[Haskell-cafe] Re: Bringing Erlang to Haskell

2005-12-12 Thread Joel Reymont
Just to elaborate a bit... On Dec 12, 2005, at 4:00 PM, Joel Reymont wrote: 1) Processes, aka threads with single-slot in/out mailboxes It's obvious that the thread id and the mailboxes (two TMVar's) would need to be kept together, i.e. a) data Process = ThreadId (TMVar Dynamic) (TMVar

Re: [Haskell-cafe] Tricky exception handling

2005-12-12 Thread Joel Reymont
Bulat, I would welcome suggestions for improvements. Please let me know how my code could be made more efficient and more readable, keeping in mind what I'm trying to accomplish. Notice that my logic is different from the one that you are proposing. What I want is to handle exceptions in

Re: [Haskell-cafe] Differences in optimisiation with interactive and compiled mode

2005-12-12 Thread Henning Thielemann
On Sat, 10 Dec 2005, Tomasz Zielonka wrote: On Thu, Dec 08, 2005 at 06:38:45PM +0100, Henning Thielemann wrote: On Thu, 8 Dec 2005, Branimir Maksimovic wrote: program performs search replace on a String http://www.haskell.org/pipermail/haskell-cafe/2005-April/009692.html Neat!

Re: [Haskell-cafe] Differences in optimisiation with interactive and comp

2005-12-12 Thread Henning Thielemann
On Sun, 11 Dec 2005, Branimir Maksimovic wrote: This one is fastest,not much, but is. So here it goes: your version, then Daniel's, then mine. What about a Wiki page containing a searchreplace function competition? :-] ___ Haskell-Cafe mailing

[Haskell-cafe] Safely polymorphic unsafePerformIO

2005-12-12 Thread Joel Reymont
On Dec 12, 2005, at 11:31 AM, Bulat Ziganshin wrote: Hello Joel, this code really looks strange: you asks to create global veriable, but don't say its type :) polymorhism is for functions definitions, any concrete data in Haskell have concrete type It's a long story but I'll try to explain.

Re: [Haskell-cafe] Substring replacements

2005-12-12 Thread Branimir Maksimovic
From: Daniel Fischer [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: Haskell-Cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Mon, 12 Dec 2005 16:15:46 +0100 Earlier today: Sorry, but Prelude SearchRep searchReplace abaaba ## abababaaba abababaaba

Re: [Haskell-cafe] [Newbie] Why or why not haskell ?

2005-12-12 Thread Henning Thielemann
On Sun, 11 Dec 2005, Tomasz Zielonka wrote: I would like to see some support in tools for enforcing such a coding policy. It could look like this - a function written using only safe components would be marked as safe. Every unsafe feature like FFI, unsafePerformIO, etc. would taint a

Re: [Haskell-cafe] Opening the same file multiple times

2005-12-12 Thread Donn Cave
Quoth Einar Karttunen ekarttun@cs.helsinki.fi: ... | *** Exception: z: openFile: resource busy (file is locked) Now that I have access to a platform where ghc builds, I can duplicate your results - and in case it helps, here's another work-around. Apparently this feature uses POSIX filesystem

Re: [Haskell-cafe] Opening the same file multiple times

2005-12-12 Thread Duncan Coutts
On Mon, 2005-12-12 at 09:52 -0800, Donn Cave wrote: Of course there's a risk that the authors of ghc may notice that we're doing this and come up with a way to thwart it, but it seems to me that between interfering with legitimate applications and not working reliably anyway, there'd be a

Re: [Haskell-cafe] c2hs seems to ignore the types I give it when generating foreign import declarations

2005-12-12 Thread Benjamin Franksen
On Monday 12 December 2005 02:17, Manuel M T Chakravarty wrote: The darcs version of c2hs darcs get --partial http://www.cse.unsw.edu.au/~chak/repos/c2hs/ now permits the use of a `nocode' keyword ... Hello not directly related, but are there any plans to add the (still?) missing 'enum

[Haskell-cafe] Enforcing coding policy (was: Why or why not haskell ?)

2005-12-12 Thread Nils Anders Danielsson
On Sun, 11 Dec 2005, Tomasz Zielonka [EMAIL PROTECTED] wrote: I would like to see some support in tools for enforcing such a coding policy. It could look like this - a function written using only safe components would be marked as safe. Every unsafe feature like FFI, unsafePerformIO, etc.

RE: [Haskell-cafe] Opening the same file multiple times

2005-12-12 Thread Simon Marlow
On 12 December 2005 17:53, Donn Cave wrote: Quoth Einar Karttunen ekarttun@cs.helsinki.fi: ... *** Exception: z: openFile: resource busy (file is locked) Now that I have access to a platform where ghc builds, I can duplicate your results - and in case it helps, here's another work-around.