Created
August 22, 2011 03:02
-
-
Save maoe/1161569 to your computer and use it in GitHub Desktop.
参照透明性を破るSTの使い方
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 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