[Haskell-cafe] Monad woes
Jeremy Shaw
jeremy at n-heptane.com
Sun Aug 23 11:21:01 EDT 2009
Also, you could define a forkM function like this:
forkM :: M () -> M ThreadId
forkM (M r) = M $ mapReaderT forkIO r
which could be used like this:
test = runM "foo" $ do
forkM $ loop callback
liftIO $ print "here"
If we were to expand forkM in test, we would get something like:
test' = runM "foo" $ do
env <- ask
liftIO $ forkIO (runM env $ loop callback)
liftIO $ print "here"
So, this does not change the 'rule' of forkIO having to come before a
runM. It just wraps it up nicely.
- jeremy
More information about the Haskell-Cafe
mailing list