Skip to content

Instantly share code, notes, and snippets.

@miguel-vila
Created April 19, 2015 20:55
Show Gist options
  • Save miguel-vila/81e0118d50ec31f25b7a to your computer and use it in GitHub Desktop.
Save miguel-vila/81e0118d50ec31f25b7a to your computer and use it in GitHub Desktop.
import Data.IORef
readAndPrint :: IORef Int -> IO ()
readAndPrint ioRef = do
n <- readIORef ioRef
print $ "ioRef = " ++ show n
main = do
ioRef <- newIORef 3
readAndPrint ioRef -- "ioRef 3"
modifyIORef ioRef (+2)
readAndPrint ioRef -- "ioRef 5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment