-
-
Save Rembane/faa60107d2c7add230ff5dfd36a9c4c1 to your computer and use it in GitHub Desktop.
This file contains 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 Control.Monad | |
import Data.IORef | |
doubler :: IORef Int -> IO () | |
doubler i = do | |
newValue <- readIORef i | |
writeIORef i (2 * newValue) | |
main :: IO () | |
main = do | |
a <- newIORef 1 | |
let xs = [a, a, a] | |
mapM_ doubler xs | |
mapM_ (readIORef >=> print) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment