I'm trying to understand why some code isn't behaving as I'd expect, and to determine whether it's a bug or not (and where that bug might be). Here's the simplest version of the code:
import Data.ByteString.Internal (inlinePerformIO)
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
main :: IO ()
main = do
vm <- VM.new 1
VM.write vm 0 'A'
let x = inlinePerformIO $ VM.write vm 0 'B'
x `seq` (V.freeze vm >>= print)
A more complete example is available on lpaste[1].
The problem is that I would expect the output to be "B", but in fact "A" is still printed. From the longer paste that I linked to, you can see that:
* When using unsafePerformIO and unsafeDupablePerformIO, the semantics work as I would have expected: "B" is printed after forcing evaluation of the result.