Re: [Haskell-cafe] Interruptible threads with IO loops

2011-12-21 Thread Bas van Dijk
On 21 December 2011 09:52, Fedor Gogolev wrote: > I'm trying to get some threads that I can stop and get last > values that was computed (and that values are IO values, in fact). I'm not sure it's what you need but you might want to look at: http://hackage.haskell.org/package/Workflow Bas

Re: [Haskell-cafe] Interruptible threads with IO loops

2011-12-21 Thread Gregory Crosswhite
On Dec 21, 2011, at 6:52 PM, Fedor Gogolev wrote: > Hello. I'm trying to get some threads that I can stop and get last > values that was computed (and that values are IO values, in fact). > Here is my first approach: > [...] > tick :: Int -> IO Int > tick v = return $ v + 1 > [...] > The problem

Re: [Haskell-cafe] Interruptible threads with IO loops

2011-12-21 Thread Felipe Almeida Lessa
Suggestion: use an IORef and asynchronous exceptions, see below for untested code. On Wed, Dec 21, 2011 at 6:52 AM, Fedor Gogolev wrote: > Hello. I'm trying to get some threads that I can stop and get last > values that was computed (and that values are IO values, in fact). > Here is my first app

[Haskell-cafe] Interruptible threads with IO loops

2011-12-21 Thread Fedor Gogolev
Hello. I'm trying to get some threads that I can stop and get last values that was computed (and that values are IO values, in fact). Here is my first approach: module Main where import Control.Concurrent (MVar, threadDelay, forkIO, newMVar, putMVar, readMVar) tick :: Int -> IO Int tick v = retu