[Haskell-cafe] Re: ANN: forkable-monad 0.1

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Apr 21 11:54:06 EDT 2010


David Anderson wrote:
> Dear Haskellers,
> 
> I'm happy, and only slightly intimidated, to announce the initial
> release of forkable-monad.
> 
> The short version is that forkable-monad exports a replacement forkIO
> that lets you do this:
> 
> type MyMonad = ReaderT Config (StateT Ctx IO)
> 
> startThread :: MyMonad ThreadId
> startThread = forkIO threadMain
> 
> threadMain :: MyMonad ()
> threadMain = forever $ liftIO $ putStrLn "Painless monad stack forking!"
> 
> Note the lack of monad stack deconstruction and reconstruction to
> transport it over to the new thread. You'll find the details in the
> Haddock documentation for the module.

Nice work!

It appears to me that this is subsumed by the recent  MonadMorphIO
proposal that Anders Kaseorg came up with, though?

   http://article.gmane.org/gmane.comp.lang.haskell.libraries/12902


   fork :: MonadMorphIO m => m () -> m ()
   fork m = morphIO $ \down -> forkIO (down m >> return ())
                               >> down (return ())


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



More information about the Haskell-Cafe mailing list