[Haskell-cafe] MState: A consistent State monad for concurrent applications

Matthew Gruen wikigracenotes at gmail.com
Fri Jul 2 21:27:11 EDT 2010


On Fri, Jul 2, 2010 at 4:59 PM, Nils Schweinsberg <ml at n-sch.de> wrote:
> And here wo go. MState on hackage:
>
> http://hackage.haskell.org/package/mstate
>
> My first hackage library. :)

Awesome. I needed something like that once, too, down to the same type
signature for the fork function. Here's an instance from my code:

instance MonadFork (ReaderT s IO) where
    fork newT = ask >>= liftIO . forkIO . runReaderT newT

since you seem to be using mtl, feel free to integrate it in some form
if you like, small though it is. ReaderT over concurrent primitives is
nice because forking is just that easy. I just used MVars for my state
monad; yours is better (more sophisticated).

Cheers,
Matt


More information about the Haskell-Cafe mailing list