`INLINE` pragma on where clause ignored by GHC
In this program GHC decides to ingore the INLINE pragma:
module M (foo) where
import Prelude hiding ( succ )
import qualified Prelude as Prelude
succ :: Enum e => e -> e
succ !x = Prelude.succ x
{-# NOINLINE foo #-}
foo :: (Num e, Enum e) => Bool -> e -> e
foo b x =
if b
then succ $ large x
else large x
where
{-# INLINE large #-}
large x = succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ
. succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ . succ $ x
If I move large
to the top level or give the local version a type signature it get's inlined as expected.
To me this is very surprising behavior. I reproduced this with a fairly recent master and 9.6.2 when using -O
.