Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class PrimConstruct prim where
- 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
- 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
- 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
- class PrimDetails prim where
- summarizePrim :: prim wX wY -> [SummDetail]
- class PrimSift prim where
- siftForPending :: FL prim wX wY -> Sealed (FL prim wX)
- class PrimShow prim where
- showPrim :: FileNameFormat -> prim wA wB -> Doc
- showPrimCtx :: ApplyMonad (ApplyState prim) m => FileNameFormat -> prim wA wB -> m Doc
- class PrimRead prim where
- readPrim :: FileNameFormat -> Parser (Sealed (prim wX))
- class PrimApply prim where
- applyPrimFL :: ApplyMonad (ApplyState prim) m => FL prim 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
- mangleUnravelled :: Unravelled prim wX -> Maybe (Mangled prim wX)
- type Mangled prim wX = Sealed (FL prim wX)
- type Unravelled prim wX = [Sealed (FL prim wX)]
- primCleanMerge :: (Commute prim, Invert prim) => PartialMergeFn prim prim
Documentation
class PrimConstruct prim where Source #
addfile :: AnchoredPath -> prim wX wY Source #
rmfile :: AnchoredPath -> prim wX wY Source #
adddir :: AnchoredPath -> prim wX wY Source #
rmdir :: AnchoredPath -> prim wX wY Source #
move :: AnchoredPath -> AnchoredPath -> prim wX wY Source #
changepref :: String -> String -> String -> prim wX wY Source #
hunk :: AnchoredPath -> Int -> [ByteString] -> [ByteString] -> prim wX wY Source #
tokreplace :: AnchoredPath -> String -> String -> String -> prim wX wY Source #
binary :: AnchoredPath -> ByteString -> ByteString -> prim wX wY Source #
primFromHunk :: FileHunk wX wY -> prim wX wY Source #
Instances
class PrimCanonize prim where Source #
tryToShrink :: FL prim wX wY -> FL prim wX wY Source #
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 Source #
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 Source #
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 Source #
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) Source #
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) Source #
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) Source #
If primCoalesce
is addition, then this is subtraction.
Just r == primCoalesce p q => primDecoalesce r p == Just q
Instances
class PrimClassify prim where Source #
primIsAddfile :: prim wX wY -> Bool Source #
primIsRmfile :: prim wX wY -> Bool Source #
primIsAdddir :: prim wX wY -> Bool Source #
primIsRmdir :: prim wX wY -> Bool Source #
primIsMove :: prim wX wY -> Bool Source #
primIsHunk :: prim wX wY -> Bool Source #
primIsTokReplace :: prim wX wY -> Bool Source #
primIsBinary :: prim wX wY -> Bool Source #
primIsSetpref :: prim wX wY -> Bool Source #
is_filepatch :: prim wX wY -> Maybe AnchoredPath Source #
Instances
class PrimDetails prim where Source #
summarizePrim :: prim wX wY -> [SummDetail] Source #
Instances
PrimDetails Prim Source # | |
Defined in Darcs.Patch.Prim.V1.Details summarizePrim :: Prim wX wY -> [SummDetail] Source # | |
PrimDetails Prim Source # | |
Defined in Darcs.Patch.Prim.FileUUID.Details summarizePrim :: Prim wX wY -> [SummDetail] Source # | |
PrimDetails Prim Source # | |
Defined in Darcs.Patch.V2.Prim summarizePrim :: Prim wX wY -> [SummDetail] Source # | |
PrimDetails Prim Source # | |
Defined in Darcs.Patch.V1.Prim summarizePrim :: Prim wX wY -> [SummDetail] Source # | |
PrimDetails p => PrimDetails (PrimWithName name p) Source # | |
Defined in Darcs.Patch.Prim.WithName summarizePrim :: PrimWithName name p wX wY -> [SummDetail] Source # |
class PrimSift prim where Source #
siftForPending :: FL prim wX wY -> Sealed (FL prim wX) Source #
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
PrimSift Prim Source # | |
Defined in Darcs.Patch.Prim.V1 | |
PrimSift Prim Source # | |
Defined in Darcs.Patch.Prim.FileUUID.Coalesce | |
PrimSift Prim Source # | |
Defined in Darcs.Patch.V2.Prim | |
PrimSift Prim Source # | |
Defined in Darcs.Patch.V1.Prim |
class PrimShow prim where Source #
showPrim :: FileNameFormat -> prim wA wB -> Doc Source #
showPrimCtx :: ApplyMonad (ApplyState prim) m => FileNameFormat -> prim wA wB -> m Doc Source #
Instances
ApplyState Prim ~ Tree => PrimShow Prim Source # | |
Defined in Darcs.Patch.Prim.V1.Show showPrim :: FileNameFormat -> Prim wA wB -> Doc Source # showPrimCtx :: ApplyMonad (ApplyState Prim) m => FileNameFormat -> Prim wA wB -> m Doc Source # | |
PrimShow Prim Source # | |
Defined in Darcs.Patch.Prim.FileUUID.Show showPrim :: FileNameFormat -> Prim wA wB -> Doc Source # showPrimCtx :: ApplyMonad (ApplyState Prim) m => FileNameFormat -> Prim wA wB -> m Doc Source # |
class PrimApply prim where Source #
applyPrimFL :: ApplyMonad (ApplyState prim) m => FL prim wX wY -> m () Source #
Instances
PrimApply Prim Source # | |
Defined in Darcs.Patch.Prim.V1.Apply applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () Source # | |
PrimApply Prim Source # | |
Defined in Darcs.Patch.Prim.FileUUID.Apply applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () Source # | |
PrimApply Prim Source # | |
Defined in Darcs.Patch.V2.Prim applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () Source # | |
PrimApply Prim Source # | |
Defined in Darcs.Patch.V1.Prim applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () Source # | |
PrimApply p => PrimApply (PrimWithName name p) Source # | |
Defined in Darcs.Patch.Prim.WithName applyPrimFL :: ApplyMonad (ApplyState (PrimWithName name p)) m => FL (PrimWithName name p) wX wY -> m () Source # |
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) Source #
class PrimMangleUnravelled prim where Source #
mangleUnravelled :: Unravelled prim wX -> Maybe (Mangled prim wX) Source #
Mangle conflicting alternatives if possible.
Instances
PrimMangleUnravelled Prim Source # | |
Defined in Darcs.Patch.Prim.V1.Mangle mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) Source # | |
PrimMangleUnravelled Prim Source # | |
Defined in Darcs.Patch.Prim.FileUUID mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) Source # | |
PrimMangleUnravelled Prim Source # | |
Defined in Darcs.Patch.V2.Prim mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) Source # | |
PrimMangleUnravelled Prim Source # | |
Defined in Darcs.Patch.V1.Prim mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) Source # |
type Unravelled prim wX = [Sealed (FL prim wX)] Source #
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 Source #