Skip to content

Instantly share code, notes, and snippets.

@maoe
Created August 22, 2011 03:02
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 maoe/1161569 to your computer and use it in GitHub Desktop.
Save maoe/1161569 to your computer and use it in GitHub Desktop.
参照透明性を破るSTの使い方
module UnsafeST where
import Control.Monad.ST (runST, unsafeIOToST)
import Data.Unique (newUnique, hashUnique)
f :: () -> Int
f _ = hashUnique $ runST $ unsafeIOToST newUnique
main :: IO ()
main = do
print $ f () -- => 1
print $ f () -- => 2
print $ f () -- => 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment