darcs-2.18.5: a distributed, interactive, smart revision control system

Maintainer | darcs-devel@darcs.net
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Darcs.Patch.Merge

Contents

- Classes
- Functions
- Properties

Description

Synopsis

- class CleanMerge (p :: Type -> Type -> Type) where
  - cleanMerge :: (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY)
- class CleanMerge p => Merge (p :: Type -> Type -> Type) where
  - merge :: (p :\/: p) wX wY -> (p :/\: p) wX wY
- selfMerger :: forall (p :: Type -> Type -> Type). Merge p => MergeFn p p
- swapMerger :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn q p
- mergerIdFL :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn p (FL q)
- mergerFLId :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn (FL p) q
- mergerFLFL :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn (FL p) (FL q)
- cleanMergeFL :: forall (p :: Type -> Type -> Type). CleanMerge p => PartialMergeFn p (FL p)
- mergeFL :: forall (p :: Type -> Type -> Type) wX wY. Merge p => (p :\/: FL p) wX wY -> (FL p :/\: p) wX wY
- swapMerge :: forall (p :: Type -> Type -> Type) wX wY. Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY
- swapCleanMerge :: forall (p :: Type -> Type -> Type) wX wY. CleanMerge p => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY)
- mergeList :: forall (p :: Type -> Type -> Type) wX. CleanMerge p => [Sealed (FL p wX)] -> Either (Sealed (FL p wX), Sealed (FL p wX)) (Sealed (FL p wX))
- prop_mergeSymmetric :: forall (p :: Type -> Type -> Type) wX wY. (Eq2 p, Merge p) => (p :\/: p) wX wY -> Bool
- prop_mergeCommute :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, Eq2 p, Merge p) => (p :\/: p) wX wY -> Bool

# Classes

class CleanMerge (p :: Type -> Type -> Type) where #

Class of patches that can, possibly, be merged cleanly, that is, without conflict.

Every patch type can be made an instance of `CleanMerge` in a trivial way by defining ``cleanMerge` _ = `Nothing``, which vacuously conforms to all required laws.

Instances should obey the following laws:

symmetry

      cleanMerge (p :\/: q) == Just (q' :/\: p') <=> cleanMerge (q :\/: p) == Just (p' :/\: q')

If an instance ``Commute` p` exists, then we also require

merge-commute

      cleanMerge (p :\/: q) == Just (q' :/\: p') ==> commute (p :> q') == Just (q :> p')

  that is, the two branches of a clean merge commute to each other.

If an instance ``Invert` p` exists, then we also require

square-merge

      cleanMerge (p :\/: q) == Just (q' :/\: p') => cleanMerge (invert p :\/: q') == Just (q :/\: invert p')

  Here is a picture that explains why we call this square-merge:

          A---p--->X          A<--p^---X
          |        |          |        |
          |        |          |        |
          q        q'   =>    q        q'
          |        |          |        |
          v        v          v        v
          Y---p'-->B          Y<--p'^--B

Methods

cleanMerge :: (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY) #

#### Instances

Instances details

CleanMerge Prim # |
Instance details Defined in Darcs.Patch.Prim.FileUUID.Commute Methods cleanMerge :: (Prim :\/: Prim) wX wY -> Maybe ((Prim :/\: Prim) wX wY) #
CleanMerge Prim # |
Instance details Defined in Darcs.Patch.Prim.V1.Commute Methods cleanMerge :: (Prim :\/: Prim) wX wY -> Maybe ((Prim :/\: Prim) wX wY) #
CleanMerge Prim # |
Instance details Defined in Darcs.Patch.V1.Prim Methods cleanMerge :: (Prim :\/: Prim) wX wY -> Maybe ((Prim :/\: Prim) wX wY) #
CleanMerge Prim # |
Instance details Defined in Darcs.Patch.V2.Prim Methods cleanMerge :: (Prim :\/: Prim) wX wY -> Maybe ((Prim :/\: Prim) wX wY) #
CleanMerge p => CleanMerge (Named p) # |
Instance details Defined in Darcs.Patch.Named Methods cleanMerge :: (Named p :\/: Named p) wX wY -> Maybe ((Named p :/\: Named p) wX wY) #
(PatchId p ~ PatchInfo, CleanMerge p) => CleanMerge (PatchInfoAndG p) # |
Instance details Defined in Darcs.Patch.PatchInfoAnd Methods cleanMerge :: (PatchInfoAndG p :\/: PatchInfoAndG p) wX wY -> Maybe ((PatchInfoAndG p :/\: PatchInfoAndG p) wX wY) #
PrimPatch prim => CleanMerge (RepoPatchV1 prim) # |
Instance details Defined in Darcs.Patch.V1.Commute Methods cleanMerge :: (RepoPatchV1 prim :\/: RepoPatchV1 prim) wX wY -> Maybe ((RepoPatchV1 prim :/\: RepoPatchV1 prim) wX wY) #
PrimPatch prim => CleanMerge (RepoPatchV2 prim) # |
Instance details Defined in Darcs.Patch.V2.RepoPatch Methods cleanMerge :: (RepoPatchV2 prim :\/: RepoPatchV2 prim) wX wY -> Maybe ((RepoPatchV2 prim :/\: RepoPatchV2 prim) wX wY) #
CleanMerge p => CleanMerge (FL p) # |
Instance details Defined in Darcs.Patch.Merge Methods cleanMerge :: (FL p :\/: FL p) wX wY -> Maybe ((FL p :/\: FL p) wX wY) #
(SignedId name, CleanMerge p) => CleanMerge (PrimWithName name p) # |
Instance details Defined in Darcs.Patch.Prim.WithName Methods cleanMerge :: (PrimWithName name p :\/: PrimWithName name p) wX wY -> Maybe ((PrimWithName name p :/\: PrimWithName name p) wX wY) #
(SignedId name, StorableId name, PrimPatch prim) => CleanMerge (RepoPatchV3 name prim) # |
Instance details Defined in Darcs.Patch.V3.Core Methods cleanMerge :: (RepoPatchV3 name prim :\/: RepoPatchV3 name prim) wX wY -> Maybe ((RepoPatchV3 name prim :/\: RepoPatchV3 name prim) wX wY) #

class CleanMerge p => Merge (p :: Type -> Type -> Type) where #

Patches that can always be merged, even if they conflict.

Instances should obey the following laws:

symmetry

      merge (p :\/: q) == q' :/\: p' <=> merge (q :\/: p) == p' :/\: q'

merge-commute

      merge (p :\/: q) == q' :/\: p' ==> commute (p :> q') == Just (q :> p')

  that is, the two branches of a merge commute to each other.

extension

      cleanMerge (p :\/: q) == Just (q' :/\: p') => merge (p :\/: q) == q' :/\: p'

  that is, `merge` is an extension of `cleanMerge`.

Methods

merge :: (p :\/: p) wX wY -> (p :/\: p) wX wY #

#### Instances

Instances details

Merge p => Merge (Named p) # |
Instance details Defined in Darcs.Patch.Named Methods merge :: (Named p :\/: Named p) wX wY -> (Named p :/\: Named p) wX wY #
(PatchId p ~ PatchInfo, Merge p) => Merge (PatchInfoAndG p) # |
Instance details Defined in Darcs.Patch.PatchInfoAnd Methods merge :: (PatchInfoAndG p :\/: PatchInfoAndG p) wX wY -> (PatchInfoAndG p :/\: PatchInfoAndG p) wX wY #
PrimPatch prim => Merge (RepoPatchV1 prim) # |
Instance details Defined in Darcs.Patch.V1.Commute Methods merge :: (RepoPatchV1 prim :\/: RepoPatchV1 prim) wX wY -> (RepoPatchV1 prim :/\: RepoPatchV1 prim) wX wY #
PrimPatch prim => Merge (RepoPatchV2 prim) # |
Instance details Defined in Darcs.Patch.V2.RepoPatch Methods merge :: (RepoPatchV2 prim :\/: RepoPatchV2 prim) wX wY -> (RepoPatchV2 prim :/\: RepoPatchV2 prim) wX wY #
Merge p => Merge (FL p) # |
Instance details Defined in Darcs.Patch.Merge Methods merge :: (FL p :\/: FL p) wX wY -> (FL p :/\: FL p) wX wY #
(SignedId name, StorableId name, PrimPatch prim) => Merge (RepoPatchV3 name prim) # |
Instance details Defined in Darcs.Patch.V3.Core Methods merge :: (RepoPatchV3 name prim :\/: RepoPatchV3 name prim) wX wY -> (RepoPatchV3 name prim :/\: RepoPatchV3 name prim) wX wY #

# Functions

selfMerger :: forall (p :: Type -> Type -> Type). Merge p => MergeFn p p #

Synonym for `merge`.

swapMerger :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn q p #

Swap the two patches, apply an arbitrary merge function, then swap again.

mergerIdFL :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn p (FL q) #

Lift a merge function over `p :/: q` to a merge function over `p :/: FL q`

mergerFLId :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn (FL p) q #

Lift a merge function over `p :/: q` to a merge function over `FL p :/: q`

mergerFLFL :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). MergeFn p q -> MergeFn (FL p) (FL q) #

Lift a merge function over `p :/: q` to a merge function over `FL p :/: FL q`

cleanMergeFL :: forall (p :: Type -> Type -> Type). CleanMerge p => PartialMergeFn p (FL p) #

Cleanly merge a single patch with an `FL` of patches.

mergeFL :: forall (p :: Type -> Type -> Type) wX wY. Merge p => (p :\/: FL p) wX wY -> (FL p :/\: p) wX wY #

swapMerge :: forall (p :: Type -> Type -> Type) wX wY. Merge p => (p :\/: p) wX wY -> (p :/\: p) wX wY #

Swap the two patches, `merge`, then swap again. Used to exploit `prop_mergeSymmetric` when defining `merge`.

swapCleanMerge :: forall (p :: Type -> Type -> Type) wX wY. CleanMerge p => (p :\/: p) wX wY -> Maybe ((p :/\: p) wX wY) #

Swap the two patches, `cleanMerge`, then swap again. Used to exploit `prop_cleanMergeSymmetric` when defining `cleanMerge`.

mergeList :: forall (p :: Type -> Type -> Type) wX. CleanMerge p => [Sealed (FL p wX)] -> Either (Sealed (FL p wX), Sealed (FL p wX)) (Sealed (FL p wX)) #

Combine a list of patch sequences, all starting at the same state, into a single sequence that also starts at the same state, using cleanMerge. If the merge fails, we return the two sequences that could not be merged so we can issue more detailed error messages.

# Properties

prop_mergeSymmetric :: forall (p :: Type -> Type -> Type) wX wY. (Eq2 p, Merge p) => (p :\/: p) wX wY -> Bool #

Whether the given pair of patches satisfies the symmetry law.

prop_mergeCommute :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, Eq2 p, Merge p) => (p :\/: p) wX wY -> Bool #

Whether the given pair of patches satisfies the merge-commute law.