[Haskell-cafe] forkM fails

Dan Weston westondan at imageworks.com
Fri Sep 4 18:56:37 EDT 2009


Try >> instead of `seq`.

Alberto G. Corona wrote:
> Hi
> 
> I need to execute a procedure not in the IO monad, but in an any monad:
> 
> I defined:
> 
> forkM :: Monad m=> m a ->  IO ThreadId
> forkM proc=forkIO $ proc  `seq` return()
> 
> I assumed  that seq will force the evaluation of proc and after, it
> will discard his type (m a) and return () in the IO monad.as forkIO
> expect.
> 
> however proc is not executed
> 
> Prelude> Control.Concurrent.forkIO $ print "hola"
> ThreadId 331
> "hola"
> Prelude>
> Prelude> let forkM p=Control.Concurrent.forkIO $ p `seq` return ()
> Prelude> forkM $ print "hola"
> ThreadId 493
> Prelude>
> 
> Any idea?. Thanks in advance
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 



More information about the Haskell-Cafe mailing list