Note to self

Nov 21, 2006 03:13

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)

duh, haskell, programming

Previous post Next post
Up