summaryrefslogtreecommitdiff
path: root/testsuite/tests/printer/Ppr029.hs
blob: 6018455e1211ed7e00ad16cda4c17c1214521b03 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
module Rules where

import Data.Char

{-# RULES "map-loop" [ ~  ]  forall f . map' f = map' (id . f) #-}

{-# NOINLINE map' #-}
map' f [] = []
map' f (x:xs) = f x : map' f xs

main = print (map' toUpper "Hello, World")

-- Should warn
foo1 x = x
{-# RULES "foo1" [ 1] forall x. foo1 x = x #-}

-- Should warn
foo2 x = x
{-# INLINE foo2 #-}
{-# RULES "foo2" [~ 1 ] forall x. foo2 x = x #-}

-- Should not warn
foo3 x = x
{-# NOINLINE foo3 #-}
{-# RULES "foo3" forall x. foo3 x = x #-}

{-# NOINLINE f #-}
f :: Int -> String
f x = "NOT FIRED"

{-# NOINLINE neg #-}
neg :: Int -> Int
neg = negate

{-# RULES
     "f" forall (c::Char->Int) (x::Char). f (c x) = "RULE FIRED"
 #-}