just because you have to a assume that memoization might happen, doesn't mean you can assume that memoization will happen.
import Data.IORef
stored = newIORef 0
get = do
state <- stored
state <- readIORef state
return state
set s = do
state <- stored
writeIORef state s
wontWork = do
number <- get
putStrLn (show number)
set (number + 1)
newNumber <- get
putStrLn (show newNumber)