In GHCI (version 9.0.1), the following gives back what I would expect:
ghci> import Data.IORef
ghci> ref <- newIORef ([] :: [Int])
ghci> modifyIORef ref (1:)
ghci> readIORef ref
[1]
But when I try the same thing this way:
ghci> import Data.IORef
ghci> ref = newIORef ([] :: [Int])
ghci> ref >>= \r -> modifyIORef r (1:)
ghci> ref >>= readIORef
[]
An empty list is returned, as if the modify never happened. Why does this happen? Shouldn't the output be the same?