Skip to content

"Main: thread blocked indefinitely in an MVar operation" in fixIO

I'm not sure whether such behavior is expected, but this program

import System.IO

main = fixIO (\x -> return 1) >>= print

prints "1"; and this

import System.IO

main = fixIO (\(x, _) -> return (1, print x)) >>= print . fst

prints "Main: thread blocked indefinitely in an MVar operation". This behavior can be fixed with additional ~ as alexbiehl said below.

Also, this program with mdo

{-# LANGUAGE RecursiveDo #-}

main = mdo
  print x
  x <- return 1
  return ()

prints "Main: thread blocked indefinitely in an MVar operation".

Edited by nickkuk
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information