Skip to content

Instantly share code, notes, and snippets.

@weidagang
Created March 2, 2017 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weidagang/0fcff09b9390e35b1a9f1ce8efadd945 to your computer and use it in GitHub Desktop.
Save weidagang/0fcff09b9390e35b1a9f1ce8efadd945 to your computer and use it in GitHub Desktop.
IORef
import Data.IORef
main :: IO ()
main = do
putStrLn "Create a mutable state 0."
ref <- newIORef (0 :: Int)
putStrLn "Increase by 1."
modifyIORef ref (+1)
result <- readIORef ref
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment