Skip to content

Instantly share code, notes, and snippets.

@Rembane
Last active June 13, 2023 10:48
Show Gist options
  • Save Rembane/faa60107d2c7add230ff5dfd36a9c4c1 to your computer and use it in GitHub Desktop.
Save Rembane/faa60107d2c7add230ff5dfd36a9c4c1 to your computer and use it in GitHub Desktop.
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