[darcs-devel] [patch1880] decouple RepoPatchV3 impl from NamedPrim

Ben Franksen bugs at darcs.net
Fri Aug 16 07:58:37 UTC 2019


Ben Franksen <ben.franksen at online.de> added the comment:

> I wanted to write a small prim type to play with examples of
> V3 patches where I could control conflicts directly and could
> think about things just as names as we do in theory discussions.
> But RepoPatchV3 requires constructing PatchInfos and that's not
> exactly lightweight.

Hm, yes. That sounds reasonable.

> This is yet another layer of abstraction, but on the other hand
> the changes were surprisingly simple and I think it's good for
> our code to make sure that RepoPatchV3 doesn't get too cosy
> with NamedPrim in the long-term.

The idea isn't bad in principle, but I really don't like the renaming of
RepoPatchV3 to RepoPatchV3Core. This is ugly. Instead, I think you
should define the "real" RepoPatchV3 in module Darcs.Patch.V3 and
resolve the name collision by importing Darcs.Patch.V3.Core qualified.

I wonder if PrimContainer should rather be a class of container types,
that is types of kind (* -> * -> *) -> * -> * -> *. This would remove
the need for the PrimContents type family. In practice, even for your
simple prim patch type, you would need to attach a name to them somehow.
This may slightly complicate your simple prim type (because you have to
attach the name with a wrapper) but I think it would be clearer and
improve type inference.

I would also try to find a way to get rid of the superclass constraints
if possible. IME these are almost always a mistake and make things
needlessly inflexible. If we define PrimContainer as a container class
as indicated above, we could factor most of the lifting of prim to
NamedPrim instances generically to Darcs.Patch.Prim.Container. This
would in turn also simplify your simple prim type.

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


More information about the darcs-devel mailing list