Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Darcs.Patch.Prim.Class
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 #
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
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
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
class PrimDetails prim where #
Methods
summarizePrim :: prim wX wY -> [SummDetail] #
Instances
PrimDetails Prim # | |
Defined in Darcs.Patch.Prim.FileUUID.Details Methods summarizePrim :: Prim wX wY -> [SummDetail] # | |
PrimDetails Prim # | |
Defined in Darcs.Patch.Prim.V1.Details Methods summarizePrim :: Prim wX wY -> [SummDetail] # | |
PrimDetails Prim # | |
Defined in Darcs.Patch.V1.Prim Methods summarizePrim :: Prim wX wY -> [SummDetail] # | |
PrimDetails Prim # | |
Defined in Darcs.Patch.V2.Prim Methods summarizePrim :: Prim wX wY -> [SummDetail] # | |
PrimDetails p => PrimDetails (PrimWithName name p) # | |
Defined in Darcs.Patch.Prim.WithName Methods summarizePrim :: PrimWithName name p wX wY -> [SummDetail] # |
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
PrimSift Prim # | |
Defined in Darcs.Patch.Prim.FileUUID.Coalesce | |
PrimSift Prim # | |
Defined in Darcs.Patch.Prim.V1 | |
PrimSift Prim # | |
Defined in Darcs.Patch.V1.Prim | |
PrimSift Prim # | |
Defined in Darcs.Patch.V2.Prim |
Methods
showPrim :: FileNameFormat -> prim wA wB -> Doc #
showPrimCtx :: ApplyMonad (ApplyState prim) m => FileNameFormat -> prim wA wB -> m Doc #
Instances
PrimShow Prim # | |
Defined in Darcs.Patch.Prim.FileUUID.Show Methods showPrim :: FileNameFormat -> Prim wA wB -> Doc # showPrimCtx :: ApplyMonad (ApplyState Prim) m => FileNameFormat -> Prim wA wB -> m Doc # | |
ApplyState Prim ~ Tree => PrimShow Prim # | |
Defined in Darcs.Patch.Prim.V1.Show Methods showPrim :: FileNameFormat -> Prim wA wB -> Doc # showPrimCtx :: ApplyMonad (ApplyState Prim) m => FileNameFormat -> Prim wA wB -> m Doc # |
Methods
readPrim :: FileNameFormat -> Parser (Sealed (prim wX)) #
Instances
PrimRead Prim # | |
Defined in Darcs.Patch.Prim.FileUUID.Read | |
PrimRead Prim # | |
Defined in Darcs.Patch.Prim.V1.Read |
Methods
applyPrimFL :: ApplyMonad (ApplyState prim) m => FL prim wX wY -> m () #
Instances
PrimApply Prim # | |
Defined in Darcs.Patch.Prim.FileUUID.Apply Methods applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () # | |
PrimApply Prim # | |
Defined in Darcs.Patch.Prim.V1.Apply Methods applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () # | |
PrimApply Prim # | |
Defined in Darcs.Patch.V1.Prim Methods applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () # | |
PrimApply Prim # | |
Defined in Darcs.Patch.V2.Prim Methods applyPrimFL :: ApplyMonad (ApplyState Prim) m => FL Prim wX wY -> m () # | |
PrimApply p => PrimApply (PrimWithName name p) # | |
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
PrimMangleUnravelled Prim # | |
Defined in Darcs.Patch.Prim.FileUUID Methods mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) # | |
PrimMangleUnravelled Prim # | |
Defined in Darcs.Patch.Prim.V1.Mangle Methods mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) # | |
PrimMangleUnravelled Prim # | |
Defined in Darcs.Patch.V1.Prim Methods mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) # | |
PrimMangleUnravelled Prim # | |
Defined in Darcs.Patch.V2.Prim Methods mangleUnravelled :: Unravelled Prim wX -> Maybe (Mangled Prim wX) # |
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 #