diff options
author | Douglas Wilson <douglas.wilson@gmail.com> | 2022-10-04 20:37:17 +0100 |
---|---|---|
committer | Douglas Wilson <douglas.wilson@gmail.com> | 2022-10-04 20:45:13 +0100 |
commit | 4bd0a3cdc19c46206a2e10ab7af934c934b9d119 (patch) | |
tree | 7ab9c86224d9f1634c144ddb52b2d7fa69ae046f | |
parent | a3218584a763fcd69bd7659022412648abc08a98 (diff) | |
download | haskell-4bd0a3cdc19c46206a2e10ab7af934c934b9d119.tar.gz |
-rw-r--r-- | noupdate.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/noupdate.hs b/noupdate.hs index 2caae1d0f3..86d9a64f80 100644 --- a/noupdate.hs +++ b/noupdate.hs @@ -1,4 +1,4 @@ -{-# OPTIONS_GHC -ddump-cmm -ddump-stg-final #-} +{-# OPTIONS_GHC -O2 -ddump-cmm -ddump-stg-final #-} import Debug.Trace import Control.Monad import GHC.Magic @@ -19,6 +19,8 @@ main = do replicateM_ 2 $ updating_local putStrLn "evaluating a top level reentrant thunk 2 times:" replicateM_ 2 $ reentrant_local + let y = bar "dougrulz" + replicateM_ 2 $ print y @@ -30,6 +32,16 @@ main = do updatingThunk :: IO Int updatingThunk = trace "updatingThunk" $ length . show <$> getCurrentTime +{-# noinline foo #-} +foo () = (trace "reentrantThunk" $ length . show <$> getCurrentTime) + {-# noinline reentrantThunk #-} reentrantThunk :: IO Int -reentrantThunk = noupdate (trace "reentrantThunk" $ length . show <$> getCurrentTime) +reentrantThunk = noupdate foo () + + +{-# noinline bar #-} +bar :: String -> Int +bar s = let + x = noupdate (length s) + in x |