diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/Main.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/Main.hs b/test/Main.hs new file mode 100644 index 0000000..0f21a29 --- /dev/null +++ b/test/Main.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE TemplateHaskell #-} +module Main where + +import Data.IORef (IORef, atomicModifyIORef', newIORef) + +import InitOnce + + +globalRef :: IORef Int +globalRef = $$(once [|| newIORef 0 ||]) + +{-# NOINLINE foo #-} +foo :: IO String +foo = atomicModifyIORef' globalRef (\i -> (i + 1, show i)) + +main :: IO () +main = do + putStrLn =<< foo + putStrLn =<< foo |
