Skip to content

Instantly share code, notes, and snippets.

@Bodigrim
Created December 25, 2022 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bodigrim/e545ad00cde5ec8c872f5d3c0e276bee to your computer and use it in GitHub Desktop.
Save Bodigrim/e545ad00cde5ec8c872f5d3c0e276bee to your computer and use it in GitHub Desktop.
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