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.
_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to