[darcs-devel] repo type witnesses [was: Handle the rebase patch at the repo layer]

Ben Franksen ben.franksen at online.de
Sat Jun 23 18:00:12 UTC 2018


Hi Ganesh

Am 23.06.2018 um 19:01 schrieb Ganesh Sittampalam:
> As an aside we should rename revertRepositoryChanges to
> startRepositoryChanges, or provide an alias :-) It's a very confusing
> name in this context, though it's the right name if you are abandoning a
> transaction.

Yes. I have become used to the strange naming but I remember that it was
a hurdle when I started hacking on Darcs. We should also say
commitRepositoryChanges instead of finalizeRepositoryChanges which is
more to the point.

>>> data Transaction = RO | RW
>>
>> RO stands for read-only, RW for read-write. (All names here are
>> provisional, of course, bikeshed them to your liking...)
> 
> The principle sounds good to me. I was thinking of suggesting it before,
> but I wasn't sure if you'd want more type-level tricks.

;-) I try to avoid them but here they seem justified. BTW, since the
Repository type is already abstract, it makes sense to hide the
singleton type and export a plain

> repoInTransaction :: Repository ... -> Bool

(or perhaps ... -> Transaction).

> I don't think the names matter too much as long as we clearly document
> them, but the concept of a "RO transaction" which isn't actually a
> transaction feels a bit confusing, so my suggestion is NoT | InT.
> Anything vaguely reasonable is fine with me.

Good, I like NoT | InT.

>> The Repository type gets an additional phantom type parameter for the
>> transaction state. The wT parameter can be dropped now, and wR stands
>> for recorded/tentative state. We add wP for the pending/tentative
>> pending state. More parameters should be added as appropriate e.g. for
>> the rebase state.
>>
>>> data Repository (x :: Transaction) wR wP wU
> 
> We might want to do this change in two passes, one that removes wT and
> one that adds wP, to avoid any risk of getting the parameters mixed up.
> It would mean more churn and I think a mixup is not that likely, but I
> think it'd also make the diffs easier to read.

Ha, I have been thinking exactly the same thing.

Cheers
Ben



More information about the darcs-devel mailing list