blob: 3c0b2ceecd9bc383d0f55d6bf383676de505ca0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
module Main where
{-# NOINLINE foo #-}
foo :: Int -> Int
foo x = x
{-# RULES "foo/5" forall (f :: Int -> Int). foo (f 5) = foo (f 42) #-}
-- highly suspect, of course!
main = print $ foo (let {-# NOINLINE j #-}
j :: Int -> Int
j n = n + 1 in j 5)
{-
If we're not careful, this will get rewritten to
main = print $ let <join> j n = n + 1 in foo (j 42)
which violates the join point invariant (can't invoke a join point from
non-tail context). Solution is to refuse to float join points when matching
RULES.
-}
|