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

2005-11-29 Thread Simon Marlow
On 29 November 2005 06:29, Tomasz Zielonka wrote: 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

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

2005-11-29 Thread Joel Reymont
Simon, How is this easier than just calling threadDelay? Ideally, I would be looking for something like reading from a TVar with a timeout. So that you either get a Nothing (timeout) or the value from the TVar. Can I implement it using the GHC timeout thread? Thanks, Joel On Nov

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

2005-11-29 Thread Santoemma Enrico
Doing music is a hard low level problem, a concurrency problem and is also an interesting problem for intelligent and behavioural computation. If it's true that Haskell can do its best on the second and third aspect, the undertaking seems to wrap with foreing interface one of the many good C

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

2005-11-29 Thread Philippa Cowderoy
On Tue, 29 Nov 2005, Santoemma Enrico wrote: Doing music is a hard low level problem, a concurrency problem and is also an interesting problem for intelligent and behavioural computation. If it's true that Haskell can do its best on the second and third aspect, the undertaking seems to

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

2005-11-29 Thread Simon Marlow
threadDelay is IO-only; there's no way to use threadDelay in an STM transaction. For example, if you want to wait for a TVar to go from Nothing to Just x with a timeout, you could do this: readOrTimeout :: TVar (Maybe a) - Int - STM (Maybe a) readOrTimeout t secs = do timeout -

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

2005-11-29 Thread Tomasz Zielonka
On Tue, Nov 29, 2005 at 12:00:03PM -, 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 for a TVar to go from Nothing to Just x with a timeout, you could do this: readOrTimeout :: TVar (Maybe a) - Int

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

2005-11-29 Thread Simon Marlow
On 29 November 2005 12:08, Tomasz Zielonka wrote: On Tue, Nov 29, 2005 at 12:00:03PM -, 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 for a TVar to go from Nothing to Just x with a timeout, you could

[Haskell-cafe] STM commit hooks

2005-11-29 Thread Einar Karttunen
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 the time. Aborts can be handled with: abort h = log h Abort retry atomic' h act = atomically (act `orElse` abort h) But is it

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

2005-11-29 Thread Joel Reymont
Simon, Where is this registerTimeout in the GHC code? Thanks, Joel On Nov 29, 2005, at 12:29 PM, Simon Marlow wrote: But you could also implement this using registerTimeout, albeit with some more code and an extra thread, and waitUntil requires an implementation in the runtime which

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

2005-11-29 Thread Simon Marlow
On 29 November 2005 12:47, Joel Reymont wrote: Where is this registerTimeout in the GHC code? Well, it's not there yet :-) But I've hacked up an implementation this morning so it might be in GHC 6.6. Cheers, Simon ___ Haskell-Cafe mailing

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

2005-11-29 Thread Joel Reymont
Would you share your implementation for us advanced users? I could use Tomasz's workaround in the meantime but isn't GHC 6.6 supposed to be out in a year? On Nov 29, 2005, at 12:52 PM, Simon Marlow wrote: On 29 November 2005 12:47, Joel Reymont wrote: Where is this registerTimeout in the

[Haskell-cafe] Re: wxHaskell and do statements

2005-11-29 Thread mempko
Malcolm Wallace wrote: 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

Re: [Haskell-cafe] Re: wxHaskell and do statements

2005-11-29 Thread Sebastian Sylvan
On 11/29/05, mempko [EMAIL PROTECTED] wrote: Malcolm Wallace wrote: 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.

[Haskell-cafe] Hacking Haskell in Nightclubs?

2005-11-29 Thread rd
Real-time audio is much simpler these days due to SuperCollider, a truly excellent cross platform audio synthesis server by James McCartney. http://www.audiosynth.com http://supercollider.sf.net To communicate with the server one only needs to implement the most basic aspects of the Open

[Haskell-cafe] :t main

2005-11-29 Thread Scherrer, Chad
I've been reading some of the articles about comonads, and I thought the idea of giving main the type OI () - () was pretty interesting. So I was wondering, would it be possible to allow the type of main to be inferred? It seems like IO () OI () - () OI () - IO () all make sense (at least I

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

2005-11-29 Thread Paul Hudak
[EMAIL PROTECTED] wrote: Real-time audio is much simpler these days due to SuperCollider, a truly excellent cross platform audio synthesis server by James McCartney. ... OSC messages can be timestamped, and SuperCollider has a sample accurate scheduling queue, so language timing jitter can