Created
October 1, 2021 14:40
-
-
Save kbridge/3ab70e06d2f37fb9718e99aba04797ce to your computer and use it in GitHub Desktop.
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 | |
newCounter :: IO (IO Int) | |
newCounter = do | |
n <- newIORef 0 | |
return $ do | |
modifyIORef' n (+1) | |
readIORef n | |
-- GHCi: | |
-- | |
-- a <- newCounter | |
-- a | |
-- a | |
-- a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment