-Wmissed-specialisations does not report most missed specializations and there is no alternative tool for that
It seems -Wmissed-specialisations
only report things that are not specialized due to a missing unfolding and not even all of these, becauase -Wall-missed-specialisations
reports more (especially from external libraries).
However, there is a lot of other cases when specialization doesn't go through despite GHC being supposed to try it in that case, despite a SPECIALIZE
pragma and even despite -fexpose-all-unfoldings -fspecialise-aggressively
. In many of these cases the specialization can be obtained by adding/tweaking SPECIALIZE
and by rewriting the code. However, the inability to verify if any given trick worked is crippling (tracing a call chain in Core falls among the "crippling" work modes; this is not a one screen tutorial example).
The hasNoTypeClassesExcept
feature of the inspection-testing
tool helps a lot with that, but it produced both false positives and negatives, because it only analyses the Core of the module it's called in and it ignores the context of a suspect dictionary occurence.
What would be extremely helpful is a warning that would trigger for any non-specialized function call, perhaps in two variants, one for calls of our functions, one for calls of functions from external packages. A bit less useful would be a warning that triggers whenever specialization is requested or expected according to the GHC manual but fails (but if -fexpose-all-unfoldings -fspecialise-aggressively
means "all specializations are requested" then this encompasses the previous functionality).