[Haskell-cafe] rewrite rules to specialize function according to type class?

Max Bolingbroke batterseapower at hotmail.com
Tue Feb 15 00:48:06 CET 2011

On 14 February 2011 21:43, Patrick Bahr <pa-ba at arcor.de> wrote:
> Am I doing something wrong or is it not possible for GHC to dispatch a rule
> according to type class constraints?

As you have discovered this is not possible. You can write the rule
for as many *particular* types as you like, but you can't write it in
a way that abstracts over the exact type class instance you mean. This
is a well known and somewhat tiresome issue.

I think the reason that this is not implemented is because it would
require the rule matcher to call back into the type checking machinery
to do instance lookup.


More information about the Haskell-Cafe mailing list