/Doubler.hs Secret
Last active
June 13, 2023 10:48
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 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