summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Wilson <douglas.wilson@gmail.com>2022-10-04 20:37:17 +0100
committerDouglas Wilson <douglas.wilson@gmail.com>2022-10-04 20:45:13 +0100
commit4bd0a3cdc19c46206a2e10ab7af934c934b9d119 (patch)
tree7ab9c86224d9f1634c144ddb52b2d7fa69ae046f
parenta3218584a763fcd69bd7659022412648abc08a98 (diff)
downloadhaskell-wip/dougwilson/noupdate.tar.gz
-rw-r--r--noupdate.hs16
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