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
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
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
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