[darcs-devel] [patch1844] automatically specialize merging and equality for sequences of patches with identity

Ganesh Sittampalam bugs at darcs.net
Sun Jul 7 10:22:03 UTC 2019


Ganesh Sittampalam <ganesh at earth.li> added the comment:

On 06/07/2019 21:28, Ben Franksen wrote:

> Perhaps I should make this clearer in the documentation: structural
> equality should be defined in terms of semantic equality of its
> components /if/ you promise not to access or at least not to rely on the
> internals of your components.
> 
> One way to make sure of that is to make your type parametric over it.

What kinds of properties do you want to express using structural
equality? Are they generic ones, that would make sense to use on
multiple different container types? If not we don't necessarily need a
type class, though it's still good documentation.

Either way, I'm wondering if structural equality is really a property of
a patch container rather than a patch, i.e.

 class StructuralEq2 f where
   eqsFork :: f p wA wB -> f p wA wC -> EqCheck wB wC
   (...)

that would rule out containers with two or more parameters, but would
nicely encode the idea you state about being parameteric.

>> In general I'd hope a type class would express properties that are 
>> independent of the specific internal representation of the type.
> 
> I agree. But structural equality is, like Read and Show, an exception,
> since it is, by definition, about internal representation. This is why
> it is not and should not be used inside darcs proper. It only exists
> because we need it to define properties that other classes must obey.

I'm actually a bit surprised we never want to use structural equality
within darcs itself. My original starting point for thinking we need
structural equality was a feeling that we overuse the (semantic) Eq2 (FL
p) instance. But perhaps it's right that we should always be working at
the semantic level.

If this class is just for testing it'd be nice to be flag that somehow,
e.g. with the name. Or I wonder about using a nullary type class for
that, e.g.

  class TestCode => StructuralEq2 p where
    ...

and then only define 'instance TestCode' in our test harness.

Cheers,

Ganesh

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch1844>
__________________________________


More information about the darcs-devel mailing list