snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
152 stars 61 forks source link

RULES have problems substituting polymorphic sequence types #216

Closed BebeSparkelSparkel closed 4 months ago

BebeSparkelSparkel commented 7 months ago

I have been trying to get functions like Data.Sequences.stripPrefix to be substituted with the defined rules but it is finicky if used in a function with a polymorphic collection type. It requires persistent inlining of all the functions to the final type specification to not use the "default" implementation.

It seems that a super class would get rid of this problem and allow the more efficient definition to be used.

class (IsSequence seq, Eq (Element seq)) => EqElement seq
BebeSparkelSparkel commented 4 months ago

Any thoughts on this?

snoyberg commented 4 months ago

I'm overall -1. Rewrite rules have been notoriously difficult to get to fire reliably, and a breaking API change to account for that would be worth it IMO.

BebeSparkelSparkel commented 4 months ago

@snoyberg I'm not sure what "-1" means

snoyberg commented 4 months ago

Meaning: overall not in favor.

BebeSparkelSparkel commented 4 months ago

Thanks it seemed contrary to your second sentence.