summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/simplCore/should_run/simplrun002.hs
blob: c6d9267d406420e90337aa148f1746f368644905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

-- !!! A rules test
-- At one time the rule got too specialised a type:
--
--  _R "ffoo" forall {@ a1 v :: (a1, ((), ()))} 
--	      fst @ a1 @ () (sndSnd @ a1 @ () @ () v) = fst @ a1 @ ((), ()) v


module Main where

import System.IO
import System.IO.Unsafe ( unsafePerformIO )

{-# NOINLINE [0] sndSnd #-}
-- Dont inline till last, to give the rule a chance
sndSnd (a,(b,c)) = (a,c)

trace x y = unsafePerformIO (hPutStr stderr x >> hPutStr stderr "\n" >> return y)

{-# RULES "foo" forall v .  fst (sndSnd v) = trace "Yes" (fst v) #-}

main :: IO ()
main = print (fst (sndSnd (True, (False,True))))