Created
December 25, 2022 17:09
-
-
Save Bodigrim/e545ad00cde5ec8c872f5d3c0e276bee 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
module Main where | |
import Control.Monad | |
import Debug.Trace | |
import GHC.Exts | |
import GHC.ST | |
import Data.STRef | |
foo :: Integer | |
foo = runST $ do | |
ref <- newSTRef 2 | |
forM_ [0..20] $ \i -> do | |
r <- readSTRef ref | |
writeSTRef ref (r * r) | |
readSTRef ref | |
main :: IO () | |
main = print foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment