c6d9267d406420e90337aa148f1746f368644905
[ghc.git] / testsuite / tests / simplCore / should_run / simplrun002.hs
1
2 -- !!! A rules test
3 -- At one time the rule got too specialised a type:
4 --
5 -- _R "ffoo" forall {@ a1 v :: (a1, ((), ()))}
6 -- fst @ a1 @ () (sndSnd @ a1 @ () @ () v) = fst @ a1 @ ((), ()) v
7
8
9 module Main where
10
11 import System.IO
12 import System.IO.Unsafe ( unsafePerformIO )
13
14 {-# NOINLINE [0] sndSnd #-}
15 -- Dont inline till last, to give the rule a chance
16 sndSnd (a,(b,c)) = (a,c)
17
18 trace x y = unsafePerformIO (hPutStr stderr x >> hPutStr stderr "\n" >> return y)
19
20 {-# RULES "foo" forall v . fst (sndSnd v) = trace "Yes" (fst v) #-}
21
22 main :: IO ()
23 main = print (fst (sndSnd (True, (False,True))))