<div dir="ltr"><div>Hi GHC devs,</div><div><br></div><div>I have a simple program using the streamly library, as follows, the whole code is in the same module:</div><div><br></div><div>{-# INLINE iterateState #-}<br>{-# SPECIALIZE iterateState :: Int -> SerialT (StateT Int IO) Int #-}<br>iterateState :: MonadState Int m => Int -> SerialT m Int<br>iterateState n = do<br>    x <- get<br>    if x > n<br>    then do<br>        put (x - 1)<br>        iterateState n<br>    else return x</div><div><br></div><div>main :: IO ()<br>main = do<br>    State.evalStateT (S.drain (iterateState 0)) 100000</div><div><br></div><div>Earlier the SPECIALIZE pragma was not required on iterateState, but after some refactoring in the library (the monad bind of SerialT changed a bit), this program now requires a SPECIALIZE on iterateState to trigger specialization, just INLINE also does not help.</div><div><br></div><div>My question is whether this may be expected in some conditions or is this something which can be considered a bug in the compiler? I am also curious what specifically could have made the compiler not specialize this anymore, is it the size of the function or some other threshold?</div><div><br></div><div>Thanks,</div><div>Harendra<br></div><div><br></div><div><br></div></div>