NOINLINE and INLINABLE should be legal together
Suppose (see #17752 (closed)) we have a recursive function with a RULE
elem :: Eq a => a -> [a] -> [a]
{-# NOINLNE[1] elem #-}
elem = ...elem...
{-# RULES
"elem/build" forall x (g :: forall b . (a -> b -> b) -> b -> b)
. elem x (build g) = g (\ y r -> (x == y) || r) False
#-}
The NOINLINE pragma is there to ensure elem
doesn't inline before the RULE has had a chance to fire.
But after it's had its chance to fire (and failed to do so) we may well want to specialise elem
. Since it is recursive we'd usually write
{-# INLINABLE elem #-}
But GHC doesn't allow that:
test.hs:24:15: error:
Duplicate INLINABLE pragmas for `elem'
-}
We should make it possible to have both a NOLININE[n]
pragma and an INLINABLE
pragma. There's no contradiction!
We might want to warn about NOLININE
vs INLINABLE
since it's silly to keep the unfolding for a function that cannot, ever, be inlined.
We'd need to take care that specialisation rules don't fire if we in an NOINLNE phase.