Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class Commute p => CommuteNoConflicts p where
- commuteNoConflicts :: (p :> p) wX wY -> Maybe ((p :> p) wX wY)
- mergeNoConflicts :: (Invert p, CommuteNoConflicts p) => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY)
Documentation
class Commute p => CommuteNoConflicts p where Source #
It is natural to think of conflicting patches p
and q
as
a parallel pair (p
because this is how conflicting patches arise.
But then Darcs comes along and merges them anyway by converting one of
them to a conflictor. Thus, inside a sequence of patches we may see
them as a sequential pair :\/:
q)(p
. In that case, :>
q')commute
will always
succeed, as expressed by the merge-commute law. commuteNoConflicts
is a restricted version of commute
that should fail in this case but
otherwise give the same result as commute
.
Primitive patch types have no conflictors, so for them we have
.commute
== commuteNoConflicts
Instances should obey the following laws:
Symmetry
commuteNoConflicts (p:>q) == Just (q':>p') <=> commuteNoConflicts (q':>p') == Just (p':>q)
Square-Commute (if an instance
exists)Invert
pcommuteNoConflicts (p:>q) == Just (q':>p') => commuteNoConflicts (invert p:>q') == Just (q:>invert p')
commuteNoConflicts
is a restriction ofcommute
commuteNoConflicts (p:>q) == Just r => commute (p:>q) == Just r
commuteNoConflicts :: (p :> p) wX wY -> Maybe ((p :> p) wX wY) Source #
An alternative to commute
to be used if correctness of your code
depends on the validity of the square-commute law, or to determine
whether patches are in conflict. A parallel pair of patches p
is conflicting if and only if :\/:
q
fails. Its
main use is so that we can define commuteNoConflicts
(p^:>
q)mergeNoConflicts
cleanly.
Instances
PrimPatch prim => CommuteNoConflicts (RepoPatchV1 prim) Source # | |
Defined in Darcs.Patch.V1.Commute commuteNoConflicts :: (RepoPatchV1 prim :> RepoPatchV1 prim) wX wY -> Maybe ((RepoPatchV1 prim :> RepoPatchV1 prim) wX wY) Source # | |
PrimPatch prim => CommuteNoConflicts (RepoPatchV2 prim) Source # | |
Defined in Darcs.Patch.V2.RepoPatch commuteNoConflicts :: (RepoPatchV2 prim :> RepoPatchV2 prim) wX wY -> Maybe ((RepoPatchV2 prim :> RepoPatchV2 prim) wX wY) Source # | |
(SignedId name, StorableId name, PrimPatch prim) => CommuteNoConflicts (RepoPatchV3 name prim) Source # | |
Defined in Darcs.Patch.V3.Core commuteNoConflicts :: (RepoPatchV3 name prim :> RepoPatchV3 name prim) wX wY -> Maybe ((RepoPatchV3 name prim :> RepoPatchV3 name prim) wX wY) Source # |
mergeNoConflicts :: (Invert p, CommuteNoConflicts p) => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY) Source #
The non-conflicting merge of (p
tries to commute the inverse :\/:
q)p^
of p
with q
. If it succeeds then the part of the result that corresponds
to p^
is re-inverted. This is also known as a "clean merge".
Note that to maintain consistency in the presence of conflictors we must use
use commuteNoConflicts
here and not commute
. Otherwise we run into
contradictions as explained below.
Concretely, suppose we use commute
here and that q
is a conflictor that
represents the primitive patch r
and conflicts (only) with (primitive
patch) p^
. That is, q
results from the conflicted
merge(r
, where :\/:
p^)=(s:/\:
q)s
is another conflictor. Now,
according to merge-commute we get commute(p^
, and thus
:>
q)=Just(r:>
s)mergeNoConflict(p
in contradiction to our
assumption that :\/:
q)=Just(s^:/\:
r)(p^
are in conflict i.e.
:\/:
qmergeNoConflict(p^
fails. (This argument takes for granted that
the addition of conflictors to prim patches preserves their commute
behavior. This is not yet stated as a law but all implementations obviously
adhere to it.):\/:
q)
As a side note, the fact that we now get an inverse conflictor s^
as part
of the result leads to further problems. For instance, whether our repo is
conflicted now depends on the order of patches: (p
is not conflicted,
but its commute :>
r)(q
obviously is. In fact, :>
s^)(q
is nothing else
but the (identity-preserving) "force-commute" of :>
s^)(p
, see the thread at
https://lists.osuosl.org/pipermail/darcs-devel/2017-November/018403.html.:>
r)