[darcs-devel] [patch1979] better shrinking for patches

Ben Franksen bugs at darcs.net
Sun Feb 23 08:04:20 UTC 2020


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

> Unfortunately it needed a bit more type family machinery, principally
> because we need to construct MergeableSequence (Named p) as well as
> MergeableSequence p - not in current screened, but in my unwind patches.

Hmm, I was wondering why there is no 'instance PrimBased (Named p)'.
Your remark explains that (I looked at your changes before reading it).

I would really like to see all the necessary machinery for Named patches
being added. A lot of that already seems to be there, so why not go all
the way and then actually use it to test properties for Named patches?

> So if we want to store a "prim only" version inside MergeableSequence,
> we need some way of getting both from RepoPatch prim to prim as well
> as Named (RepoPatch prim) to Named prim. That's the new OnlyPrim
> type family, with a containing class "PrimBased".

If one wants to avoid partial functions/methods, this seems to be the
way to go.

> It's unfortunate, but overall I feel it's the right thing to do: it
> means we can remove several slightly dubious instances for RepoPatches.
> Without this we'll be continually writing code where we have to assume
> there are no conflicts in a RepoPatch.

I am fine with PrimBased/OnlyPrim. There is only minimal typing
overhead, no more than I would expect is needed to get rid of the
partial methods, type inference doesn't seem to suffer, and signatures
don't become unreadable. Looks like a clear win.

However, I stumbled over one detail that isn't immediately obvious to
me. You have now added vacuous instances Shrinkable Prim for various
Prim types e.g.

instance Shrinkable V1.Prim where
  shrinkInternally _ = []
  shrinkAtEnd _ = []
  shrinkAtStart _ = []

It is unclear to me why these are needed, and I find them a bit ugly. Is
there a way to get rid of them, and if not, why are they needed?

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch1979>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 4211 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-devel/attachments/20200223/c5c92e37/attachment.key>


More information about the darcs-devel mailing list