| Paste number 33254: | Simple IORef example. |
| Pasted by: | Cale |
| When: | 3 years, 8 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+PNQ |
| Channel: | #haskell |
| Paste contents: |
import Data.IORef
mainLoop ref = do
putStrLn "Enter a value to set the IORef to, or blank to print it."
x <- getLine
if null x
then do v <- readIORef ref
print v
else writeIORef ref x
mainLoop ref
main = do
ref <- newIORef "Initial value."
mainLoop ref This paste has no annotations.