blob: 8e7c40b75c5d6e19f761f2d3ecdc61feed295c41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE BangPatterns #-}
import GHC.Exts
import System.IO.Unsafe ( unsafePerformIO )
z# :: Int -> Int#
z# _ = unsafePerformIO (putStrLn "Can you read this?") `seq` 0#
{-# NOINLINE z# #-}
f :: Int# -> Int
f _ = unsafePerformIO (putStrLn "Rewrite rule did not match? Bad!") `seq` 0
{-# NOINLINE f #-}
g :: Int -> Int
g _ = 1
{-# NOINLINE g #-}
h :: Int# -> Int
h _ = 2
{-# NOINLINE h #-}
main = print (f (z# 3))
{-# RULES "f to h.g" forall x. f x = g (h x) #-}
|