[Haskell-cafe] Help: Main: thread blocked in MVar operation

Joey Adams joeyadams3.14159 at gmail.com
Wed Oct 24 01:01:46 CEST 2012

On Tue, Oct 23, 2012 at 5:03 PM, "José A. Lopes" <jose.lopes at ist.utl.pt> wrote:
> Hey everyone,
> I changed my code I now I get the following error message
>     Main: thread blocked indefinitely in an MVar operation
> Before the change, I was using the State monad with runState.
> Then, I changed the code to use the StateT monad transformer wrapped around
> IO monad and runStateT.
> And this change introduced the error message.
> BTW I am using DoRec extension, maybe it is the source of the problem, but I
> don't know.

See if you can reproduce the problem using a small code sample.  The
problem is likely that your program is trying to use a state value
that hasn't been produced yet.

DoRec uses fixIO for the IO monad.  fixIO passes a callback its own
return value.  It's not magic; it only works if the thunk is not
forced within the callback.

Take a look at how fixIO is implemented:


More information about the Haskell-Cafe mailing list