Improving specialization, redux

David Feuer david.feuer at gmail.com
Sat Oct 25 00:34:41 UTC 2014


I spoke with Simon today, and I think I have a bit of a better idea now of
what's going on with specialization, and why it sometimes fails to
specialize things as much as it could. Apparently, the replacement of (sel
@ type dict) by sel.type is accomplished by the use of a rewrite rule
generated by the specializer when it specializes an overloaded function
using that (or something similar to that, anyway). The trouble is that as
things are currently done, there's no way in general to get the right
replacement to stick on the RHS of the rule when such forms arise in other
contexts. The type checker constructs dictionaries in type checking, but
afterwards we can't produce new ones.

The most likely way to solve this is probably to (somehow) decouple
dictionary creation and selection from type checking so as to expose those
facilities to later phases. The concept would be something vaguely like
this: instead of creating rewrite rules, the specializer would instead
check whether the appropriate dictionary already existed, and create it if
not. The simplifier would then check for a dictionary every time it
encountered a class method whose instance is determined. No, I have no idea
how much work such a change would involve.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141024/fd4ed024/attachment.html>


More information about the ghc-devs mailing list