
"Manuel M. T. Chakravarty"
Meanwhile, I think, the lack of inlining that I saw isn't connected to modules. Instead, the problem is that GHC thinks it knows more about my program than I do. More precisely, it seems to take an INLINE pragma just as an encouragement rather than a command to inline. In particular - at least if a function is large enough - it doesn't inline the function anymore if the function is used more than once.[1]
Actually, the current behaviour - at least, as I understand it - in combination with modules leads IMHO to rather inconsistent behaviour. Given a module module M (foo) where {#- INLINE foo #-} foo = <biggish definition> GHC will not inline `foo' in module Main where import M bar = ...foo a... main = ...foo b...bar... However, it will inline foo twice in case of module N (bar) where import N bar = ...foo a... module Main where import M import N main = ...foo b...bar... although it is exactly the same code. In other words, using many modules leads to larger binaries and faster code. All this is understandable given that optimisation always included heuristics. However, for programmer supplied annotations, I think, it is problematic. Cheers, Manuel