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

Gábor Lehel illissius at gmail.com
Tue Feb 15 01:11:03 CET 2011


On Tue, Feb 15, 2011 at 12:48 AM, Max Bolingbroke
<batterseapower at hotmail.com> wrote:
> 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.

This is a semi-related question I've been meaning to ask at some
point: I suppose this also means it's not possible to write a class,
write some rules for the class, and then have the rules be applied to
every instance? (I.e. you'd have to write them separately for each?)

>
> Cheers,
> Max
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Work is punishment for failing to procrastinate effectively.



More information about the Haskell-Cafe mailing list