Created
March 2, 2017 02:29
-
-
Save weidagang/0fcff09b9390e35b1a9f1ce8efadd945 to your computer and use it in GitHub Desktop.
IORef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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