a less forceful INLINE pragma
INLINE pragmas currently does two things:
- it saves an unoptimised definition of the function in the interface file, and
- it unfolds the definition at (almost) every call site, before optimising it further in situ.
I'm proposing that we have a variant of the
INLINE pragma that does (1) without necessarily unfolding the definition at every call site. GHC's simplifier already has some well-tuned heuristics for deciding whether to inline something or not based on information about the context, and when we use
INLINE we bypass all this and potentially end up with unnecessary code bloat and maybe even a loss of performance in some cases.
If we had an
INLINEABLE pragma that did (1) without forcing (2), then the decision about whether to inline or not is deferred to the call site, where the user can decide how they want to trade off code size against speed. Right now the user doesn't get to decide - the library writer does.