RE: [Haskell-cafe] STM, IO and event loops

2005-11-28 Thread Simon Peyton-Jones
A good design pattern, I think, is to have a Haskell thread dedicated to each socket. It can suck on the socket and dump what it finds into an STM channel or buffer. Then other threads (the ones doing the work) can read it transactionally. It should be find to have lots of threads, esp if

RE: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-28 Thread Simon Peyton-Jones
| Andrew Pimlott: | //about my highly spiritual essay on lazy computing of PI//: | | In addition to being clever and terribly funny, the conclusion | foreshadows (inspired?) later work on Enron [1]. | | Come on, it is improbable that Master Simon ever read my essay... I hadn't before, but I

Re: [Haskell-cafe] STM, IO and event loops

2005-11-28 Thread Joel Reymont
This is exactly what I do. I use hGetBuf with a timeout. I do not compile with -threaded, should I? Does it change anything? Also, is there a way to somehow stick all the sockets that I read from into a select to monitor input on any of them and wake up a thread once input becomes

Re: [Haskell-cafe] Haskell GUI on top of Xlib?

2005-11-28 Thread Einar Karttunen
On 26.11 22:00, Dimitry Golubovsky wrote: Thanks Duncan for this link: a very interesting reading. Duncan Coutts wrote: Are you aware of the XCB library: http://xcb.freedesktop.org/ I managed to parse the XCB XML protocol descriptions to Haskell data structures, next I'll try to emit

RE: [Haskell-cafe] STM, IO and event loops

2005-11-28 Thread Simon Marlow
On Unix with -threaded, all blocking I/O using Handles or sockets goes via the I/O manager thread, which multiplexes all the blocked I/O requests into a single select() call. If you have 20k blocked socket reads, there will be 20k lightweight Haskell threads, and probably 2 or 3 real OS threads.

Re: [Haskell-cafe] Haskell GUI on top of Xlib?

2005-11-28 Thread Dimitry Golubovsky
Einar, Are you talking about packet handling level only (i. e. same as I have now), or do you also have any of their transport algorithms (lazy request sending/response retrieval) implemented? Einar Karttunen wrote: I managed to parse the XCB XML protocol descriptions to Haskell data

Re: [Haskell-cafe] STM, IO and event loops

2005-11-28 Thread Joel Reymont
On Nov 28, 2005, at 11:32 AM, Simon Marlow wrote: On Unix with -threaded, all blocking I/O using Handles or sockets goes via the I/O manager thread, which multiplexes all the blocked I/O requests into a single select() call. If you have 20k blocked socket reads, there will be 20k lightweight

RE: [Haskell-cafe] STM, IO and event loops

2005-11-28 Thread Simon Marlow
On 28 November 2005 11:47, Joel Reymont wrote: On Nov 28, 2005, at 11:32 AM, Simon Marlow wrote: On Unix with -threaded, all blocking I/O using Handles or sockets goes via the I/O manager thread, which multiplexes all the blocked I/O requests into a single select() call. If you have 20k

[Haskell-cafe] Lazier I/O?

2005-11-28 Thread Dimitry Golubovsky
This may be a stupud question, but how to make I/O in Haskell really lazy? Here is a simple program: module Main where import System.IO import Foreign import Data.Word import Data.Char s2c :: String - [Word8] s2c s = map (fromIntegral . ord) s sendstr :: Handle - String - IO Int

Re: [Haskell-cafe] Lazier I/O?

2005-11-28 Thread David Roundy
On Mon, Nov 28, 2005 at 07:27:44AM -0500, Dimitry Golubovsky wrote: Any ideas, pointers? unsafeInterleaveIO does what you want. -- David Roundy http://www.darcs.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] wxHaskell and do statements

2005-11-28 Thread mempko
Hello, I have a program that just will not compile and I cannot figure out why. I am starting out with wxHaskell but keep getting certain errors. Here is the source: - module Main where import Graphics.UI.WX main :: IO () main = start hello hello :: IO () hello = do

Re: Re[2]: [Haskell-cafe] Monads in Scala, XSLT, Unix shell pipes was Re: Monads in ...

2005-11-28 Thread Gregory Woodhouse
On Nov 27, 2005, at 2:36 PM, Bill Wood wrote: (I'm going to do a lazy permute on your stream of consciousness; hope it terminates :-). I think the Rubicon here is the step from one to many -- one function/procedure to many, one thread to many, one processor to many, ... . Our favorite pure

Re: [Haskell-cafe] wxHaskell and do statements

2005-11-28 Thread Malcolm Wallace
mempko [EMAIL PROTECTED] writes: Hello, I have a program that just will not compile and I cannot figure out why. Wrong indentation. Tab stops are 8 spaces in Haskell, but your code seems to assume 6 spaces. - module Main where import Graphics.UI.WX main :: IO

Re: [Haskell-cafe] Lazier I/O?

2005-11-28 Thread Wolfgang Jeltsch
Am Montag, 28. November 2005 13:27 schrieb Dimitry Golubovsky: [...] What is desired is to have the IO actions perform as their results are needed. I am assuming some knowledge that those actions have only limited scope of side effects (e. g. order of outputs within a window is significant,

[Haskell-cafe] Hacking Haskell in Nightclubs?

2005-11-28 Thread Echo Nolan
Hello all, I read an article on using perl for live improvised synthesis a while ago (http://www.perl.com/pub/a/2004/08/31/livecode.html). Does anyone have thoughts in doing this is haskell? Would strong typing make jazzy programming too difficult? Regards, Echo Nolan signature.asc

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

2005-11-28 Thread Joel Reymont
Folks, How would you implement a timed read from a channel with STM? I would like to return Timeout if nothing was read from a TChan in X ms. Is this a basic two-thread timeout implementation or is there a more elegant way of implementing this using `orElse`? Thanks, Joel --

Re: [Haskell-cafe] Hacking Haskell in Nightclubs?

2005-11-28 Thread Paul Hudak
Although Haskore (haskell.org/haskore) doesn't currently support real-time music, it's something I've thought about numerous times in the past, and wish I had the time to do it... -Paul Hudak Echo Nolan wrote: Hello all, I read an article on using perl for live improvised

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

2005-11-28 Thread Tomasz Zielonka
On Mon, Nov 28, 2005 at 11:27:46PM +, Joel Reymont wrote: Folks, How would you implement a timed read from a channel with STM? I would like to return Timeout if nothing was read from a TChan in X ms. Is this a basic two-thread timeout implementation or is there a more elegant way