darcs-2.16.5: a distributed, interactive, smart revision control system
Safe HaskellSafe-Inferred
LanguageHaskell2010

Darcs.Patch.Prim.Class

Synopsis

Documentation

class PrimConstruct prim where #

Methods

addfile :: AnchoredPath -> prim wX wY #

rmfile :: AnchoredPath -> prim wX wY #

adddir :: AnchoredPath -> prim wX wY #

rmdir :: AnchoredPath -> prim wX wY #

move :: AnchoredPath -> AnchoredPath -> prim wX wY #

changepref :: String -> String -> String -> prim wX wY #

hunk :: AnchoredPath -> Int -> [ByteString] -> [ByteString] -> prim wX wY #

tokreplace :: AnchoredPath -> String -> String -> String -> prim wX wY #

binary :: AnchoredPath -> ByteString -> ByteString -> prim wX wY #

primFromHunk :: FileHunk wX wY -> prim wX wY #

Instances

Instances details
PrimConstruct Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Core

Methods

addfile :: AnchoredPath -> Prim wX wY #

rmfile :: AnchoredPath -> Prim wX wY #

adddir :: AnchoredPath -> Prim wX wY #

rmdir :: AnchoredPath -> Prim wX wY #

move :: AnchoredPath -> AnchoredPath -> Prim wX wY #

changepref :: String -> String -> String -> Prim wX wY #

hunk :: AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY #

tokreplace :: AnchoredPath -> String -> String -> String -> Prim wX wY #

binary :: AnchoredPath -> ByteString -> ByteString -> Prim wX wY #

primFromHunk :: FileHunk wX wY -> Prim wX wY #

PrimConstruct Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Core

Methods

addfile :: AnchoredPath -> Prim wX wY #

rmfile :: AnchoredPath -> Prim wX wY #

adddir :: AnchoredPath -> Prim wX wY #

rmdir :: AnchoredPath -> Prim wX wY #

move :: AnchoredPath -> AnchoredPath -> Prim wX wY #

changepref :: String -> String -> String -> Prim wX wY #

hunk :: AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY #

tokreplace :: AnchoredPath -> String -> String -> String -> Prim wX wY #

binary :: AnchoredPath -> ByteString -> ByteString -> Prim wX wY #

primFromHunk :: FileHunk wX wY -> Prim wX wY #

PrimConstruct Prim # 
Instance details

Defined in Darcs.Patch.V1.Prim

Methods

addfile :: AnchoredPath -> Prim wX wY #

rmfile :: AnchoredPath -> Prim wX wY #

adddir :: AnchoredPath -> Prim wX wY #

rmdir :: AnchoredPath -> Prim wX wY #

move :: AnchoredPath -> AnchoredPath -> Prim wX wY #

changepref :: String -> String -> String -> Prim wX wY #

hunk :: AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY #

tokreplace :: AnchoredPath -> String -> String -> String -> Prim wX wY #

binary :: AnchoredPath -> ByteString -> ByteString -> Prim wX wY #

primFromHunk :: FileHunk wX wY -> Prim wX wY #

PrimConstruct Prim # 
Instance details

Defined in Darcs.Patch.V2.Prim

Methods

addfile :: AnchoredPath -> Prim wX wY #

rmfile :: AnchoredPath -> Prim wX wY #

adddir :: AnchoredPath -> Prim wX wY #

rmdir :: AnchoredPath -> Prim wX wY #

move :: AnchoredPath -> AnchoredPath -> Prim wX wY #

changepref :: String -> String -> String -> Prim wX wY #

hunk :: AnchoredPath -> Int -> [ByteString] -> [ByteString] -> Prim wX wY #

tokreplace :: AnchoredPath -> String -> String -> String -> Prim wX wY #

binary :: AnchoredPath -> ByteString -> ByteString -> Prim wX wY #

primFromHunk :: FileHunk wX wY -> Prim wX wY #

class PrimCanonize prim where #

Methods

tryToShrink :: FL prim wX wY -> FL prim wX wY #

tryToShrink ps simplifies ps by getting rid of self-cancellations or coalescing patches

Question (Eric Kow): what properties should this have? For example, the prim1 implementation only gets rid of the first self-cancellation it finds (as far as I can tell). Is that OK? Can we try harder?

sortCoalesceFL :: FL prim wX wY -> FL prim wX wY #

sortCoalesceFL ps coalesces as many patches in ps as possible, sorting the results in some standard order.

canonize :: DiffAlgorithm -> prim wX wY -> FL prim wX wY #

It can sometimes be handy to have a canonical representation of a given patch. We achieve this by defining a canonical form for each patch type, and a function canonize which takes a patch and puts it into canonical form. This routine is used by the diff function to create an optimal patch (based on an LCS algorithm) from a simple hunk describing the old and new version of a file.

canonizeFL :: DiffAlgorithm -> FL prim wX wY -> FL prim wX wY #

canonizeFL ps puts a sequence of primitive patches into canonical form. Even if the patches are just hunk patches, this is not necessarily the same set of results as you would get if you applied the sequence to a specific tree and recalculated a diff.

Note that this process does not preserve the commutation behaviour of the patches and is therefore not appropriate for use when working with already recorded patches (unless doing amend-record or the like).

coalesce :: (prim :> prim) wX wY -> Maybe (FL prim wX wY) #

Either primCoalesce or cancel inverses.

primCoalesce (p :> q) == Just r => apply r = apply p >> apply q
primCoalesce (p :> q) == Just r => lengthFL r < 2

primCoalesce :: prim wX wY -> prim wY wZ -> Maybe (prim wX wZ) #

Coalesce adjacent patches to one with the same effect.

apply (primCoalesce p q) == apply p >> apply q

primDecoalesce :: prim wX wZ -> prim wX wY -> Maybe (prim wY wZ) #

If primCoalesce is addition, then this is subtraction.

Just r == primCoalesce p q => primDecoalesce r p == Just q

Instances

Instances details
PrimCanonize Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Coalesce

Methods

tryToShrink :: FL Prim wX wY -> FL Prim wX wY #

sortCoalesceFL :: FL Prim wX wY -> FL Prim wX wY #

canonize :: DiffAlgorithm -> Prim wX wY -> FL Prim wX wY #

canonizeFL :: DiffAlgorithm -> FL Prim wX wY -> FL Prim wX wY #

coalesce :: (Prim :> Prim) wX wY -> Maybe (FL Prim wX wY) #

primCoalesce :: Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ) #

primDecoalesce :: Prim wX wZ -> Prim wX wY -> Maybe (Prim wY wZ) #

PrimCanonize Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Coalesce

Methods

tryToShrink :: FL Prim wX wY -> FL Prim wX wY #

sortCoalesceFL :: FL Prim wX wY -> FL Prim wX wY #

canonize :: DiffAlgorithm -> Prim wX wY -> FL Prim wX wY #

canonizeFL :: DiffAlgorithm -> FL Prim wX wY -> FL Prim wX wY #

coalesce :: (Prim :> Prim) wX wY -> Maybe (FL Prim wX wY) #

primCoalesce :: Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ) #

primDecoalesce :: Prim wX wZ -> Prim wX wY -> Maybe (Prim wY wZ) #

PrimCanonize Prim # 
Instance details

Defined in Darcs.Patch.V1.Prim

Methods

tryToShrink :: FL Prim wX wY -> FL Prim wX wY #

sortCoalesceFL :: FL Prim wX wY -> FL Prim wX wY #

canonize :: DiffAlgorithm -> Prim wX wY -> FL Prim wX wY #

canonizeFL :: DiffAlgorithm -> FL Prim wX wY -> FL Prim wX wY #

coalesce :: (Prim :> Prim) wX wY -> Maybe (FL Prim wX wY) #

primCoalesce :: Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ) #

primDecoalesce :: Prim wX wZ -> Prim wX wY -> Maybe (Prim wY wZ) #

PrimCanonize Prim # 
Instance details

Defined in Darcs.Patch.V2.Prim

Methods

tryToShrink :: FL Prim wX wY -> FL Prim wX wY #

sortCoalesceFL :: FL Prim wX wY -> FL Prim wX wY #

canonize :: DiffAlgorithm -> Prim wX wY -> FL Prim wX wY #

canonizeFL :: DiffAlgorithm -> FL Prim wX wY -> FL Prim wX wY #

coalesce :: (Prim :> Prim) wX wY -> Maybe (FL Prim wX wY) #

primCoalesce :: Prim wX wY -> Prim wY wZ -> Maybe (Prim wX wZ) #

primDecoalesce :: Prim wX wZ -> Prim wX wY -> Maybe (Prim wY wZ) #

class PrimClassify prim where #

Methods

primIsAddfile :: prim wX wY -> Bool #

primIsRmfile :: prim wX wY -> Bool #

primIsAdddir :: prim wX wY -> Bool #

primIsRmdir :: prim wX wY -> Bool #

primIsMove :: prim wX wY -> Bool #

primIsHunk :: prim wX wY -> Bool #

primIsTokReplace :: prim wX wY -> Bool #

primIsBinary :: prim wX wY -> Bool #

primIsSetpref :: prim wX wY -> Bool #

is_filepatch :: prim wX wY -> Maybe AnchoredPath #

Instances

Instances details
PrimClassify Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Core

Methods

primIsAddfile :: Prim wX wY -> Bool #

primIsRmfile :: Prim wX wY -> Bool #

primIsAdddir :: Prim wX wY -> Bool #

primIsRmdir :: Prim wX wY -> Bool #

primIsMove :: Prim wX wY -> Bool #

primIsHunk :: Prim wX wY -> Bool #

primIsTokReplace :: Prim wX wY -> Bool #

primIsBinary :: Prim wX wY -> Bool #

primIsSetpref :: Prim wX wY -> Bool #

is_filepatch :: Prim wX wY -> Maybe AnchoredPath #

PrimClassify Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Core

Methods

primIsAddfile :: Prim wX wY -> Bool #

primIsRmfile :: Prim wX wY -> Bool #

primIsAdddir :: Prim wX wY -> Bool #

primIsRmdir :: Prim wX wY -> Bool #

primIsMove :: Prim wX wY -> Bool #

primIsHunk :: Prim wX wY -> Bool #

primIsTokReplace :: Prim wX wY -> Bool #

primIsBinary :: Prim wX wY -> Bool #

primIsSetpref :: Prim wX wY -> Bool #

is_filepatch :: Prim wX wY -> Maybe AnchoredPath #

PrimClassify Prim # 
Instance details

Defined in Darcs.Patch.V1.Prim

Methods

primIsAddfile :: Prim wX wY -> Bool #

primIsRmfile :: Prim wX wY -> Bool #

primIsAdddir :: Prim wX wY -> Bool #

primIsRmdir :: Prim wX wY -> Bool #

primIsMove :: Prim wX wY -> Bool #

primIsHunk :: Prim wX wY -> Bool #

primIsTokReplace :: Prim wX wY -> Bool #

primIsBinary :: Prim wX wY -> Bool #

primIsSetpref :: Prim wX wY -> Bool #

is_filepatch :: Prim wX wY -> Maybe AnchoredPath #

PrimClassify Prim # 
Instance details

Defined in Darcs.Patch.V2.Prim

Methods

primIsAddfile :: Prim wX wY -> Bool #

primIsRmfile :: Prim wX wY -> Bool #

primIsAdddir :: Prim wX wY -> Bool #

primIsRmdir :: Prim wX wY -> Bool #

primIsMove :: Prim wX wY -> Bool #

primIsHunk :: Prim wX wY -> Bool #

primIsTokReplace :: Prim wX wY -> Bool #

primIsBinary :: Prim wX wY -> Bool #

primIsSetpref :: Prim wX wY -> Bool #

is_filepatch :: Prim wX wY -> Maybe AnchoredPath #

PrimClassify p => PrimClassify (PrimWithName name p) # 
Instance details

Defined in Darcs.Patch.Prim.WithName

Methods

primIsAddfile :: PrimWithName name p wX wY -> Bool #

primIsRmfile :: PrimWithName name p wX wY -> Bool #

primIsAdddir :: PrimWithName name p wX wY -> Bool #

primIsRmdir :: PrimWithName name p wX wY -> Bool #

primIsMove :: PrimWithName name p wX wY -> Bool #

primIsHunk :: PrimWithName name p wX wY -> Bool #

primIsTokReplace :: PrimWithName name p wX wY -> Bool #

primIsBinary :: PrimWithName name p wX wY -> Bool #

primIsSetpref :: PrimWithName name p wX wY -> Bool #

is_filepatch :: PrimWithName name p wX wY -> Maybe AnchoredPath #

class PrimDetails prim where #

Methods

summarizePrim :: prim wX wY -> [SummDetail] #

Instances

Instances details
PrimDetails Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Details

Methods

summarizePrim :: Prim wX wY -> [SummDetail] #

PrimDetails Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Details

Methods

summarizePrim :: Prim wX wY -> [SummDetail] #

PrimDetails Prim # 
Instance details

Defined in Darcs.Patch.V1.Prim

Methods

summarizePrim :: Prim wX wY -> [SummDetail] #

PrimDetails Prim # 
Instance details

Defined in Darcs.Patch.V2.Prim

Methods

summarizePrim :: Prim wX wY -> [SummDetail] #

PrimDetails p => PrimDetails (PrimWithName name p) # 
Instance details

Defined in Darcs.Patch.Prim.WithName

Methods

summarizePrim :: PrimWithName name p wX wY -> [SummDetail] #

class PrimSift prim where #

Methods

siftForPending :: FL prim wX wY -> Sealed (FL prim wX) #

siftForPending ps simplifies the candidate pending patch ps through a combination of looking for self-cancellations (sequences of patches followed by their inverses), coalescing, and getting rid of any hunk/binary patches we can commute out the back

The visual image of sifting can be quite helpful here. We are repeatedly tapping (shrinking) the patch sequence and shaking it (sift). Whatever falls out is the pending we want to keep. We do this until the sequence looks about as clean as we can get it

Instances

Instances details
PrimSift Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Coalesce

Methods

siftForPending :: FL Prim wX wY -> Sealed (FL Prim wX) #

PrimSift Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1

Methods

siftForPending :: FL Prim wX wY -> Sealed (FL Prim wX) #

PrimSift Prim # 
Instance details

Defined in Darcs.Patch.V1.Prim

Methods

siftForPending :: FL Prim wX wY -> Sealed (FL Prim wX) #

PrimSift Prim # 
Instance details

Defined in Darcs.Patch.V2.Prim

Methods

siftForPending :: FL Prim wX wY -> Sealed (FL Prim wX) #

class PrimShow prim where #

Methods

showPrim :: FileNameFormat -> prim wA wB -> Doc #

showPrimCtx :: ApplyMonad (ApplyState prim) m => FileNameFormat -> prim wA wB -> m Doc #

Instances

Instances details
PrimShow Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Show

ApplyState Prim ~ Tree => PrimShow Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Show

class PrimRead prim where #

Methods

readPrim :: FileNameFormat -> Parser (Sealed (prim wX)) #

Instances

Instances details
PrimRead Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Read

PrimRead Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Read

class PrimApply prim where #

Methods

applyPrimFL :: ApplyMonad (ApplyState prim) m => FL prim wX wY -> m () #

Instances

Instances details
PrimApply Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID.Apply

Methods

applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () #

PrimApply Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Apply

Methods

applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () #

PrimApply Prim # 
Instance details

Defined in Darcs.Patch.V1.Prim

Methods

applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () #

PrimApply Prim # 
Instance details

Defined in Darcs.Patch.V2.Prim

Methods

applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () #

PrimApply p => PrimApply (PrimWithName name p) # 
Instance details

Defined in Darcs.Patch.Prim.WithName

Methods

applyPrimFL :: ApplyMonad (ApplyState (PrimWithName name p)) m => FL (PrimWithName name p) wX wY -> m () #

type PrimPatch prim = (Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCanonize prim, PrimClassify prim, PrimDetails prim, PrimApply prim, PrimSift prim, PrimMangleUnravelled prim, ReadPatch prim, ShowPatch prim, ShowContextPatch prim, PatchListFormat prim) #

class PrimMangleUnravelled prim where #

Methods

mangleUnravelled :: Unravelled prim wX -> Maybe (Mangled prim wX) #

Mangle conflicting alternatives if possible.

Instances

Instances details
PrimMangleUnravelled Prim # 
Instance details

Defined in Darcs.Patch.Prim.FileUUID

PrimMangleUnravelled Prim # 
Instance details

Defined in Darcs.Patch.Prim.V1.Mangle

PrimMangleUnravelled Prim # 
Instance details

Defined in Darcs.Patch.V1.Prim

PrimMangleUnravelled Prim # 
Instance details

Defined in Darcs.Patch.V2.Prim

type Mangled prim wX = Sealed (FL prim wX) #

Result of mangling a single Unravelled.

type Unravelled prim wX = [Sealed (FL prim wX)] #

A list of conflicting alternatives. They form a connected component of the conflict graph i.e. one transitive conflict.

primCleanMerge :: (Commute prim, Invert prim) => PartialMergeFn prim prim #