lookupBindGroupOcc: recommend names in the same namespace (#17593)
[ghc.git] / testsuite / tests / perf / should_run / T15226a.hs
1 -- T15226
2 import Control.Exception (evaluate)
3
4 -- Just in case Prelude.repeat changes for some reason.
5 import Prelude hiding (repeat)
6 import Data.Coerce
7
8 -- We want to be sure that the compiler *doesn't* know that
9 -- all the elements of the list are in WHNF, because if it
10 -- does, PrelRules may erase the seq#'s altogether.
11 repeat :: a -> [a]
12 repeat a = res
13 where res = a : res
14 {-# NOINLINE repeat #-} -- Belt *and* suspenders
15
16 newtype Foo = Foo Int
17
18 silly :: [Int] -> IO ()
19 silly = foldr go (pure ())
20 where
21 go x r = do
22 x' <- (coerce (evaluate :: Foo -> IO Foo) :: Int -> IO Int) x
23 evaluate (x' + 3) -- GHC should know that x' has been evaluated,
24 -- so this calculation will be erased entirely.
25 -- Otherwise, we'll create a thunk to pass to
26 -- evaluate.
27 r
28
29 main :: IO ()
30 -- 10,000,000 repetitions take only a twentieth of a second,
31 -- but allocations go up dramatically if the result is not
32 -- known evaluated.
33 main = silly $ take 10000000 $ repeat 1