Safe Haskell | None |
---|---|
Language | Haskell2010 |
Darcs.Patch.Prim
Synopsis
- class PrimApply (prim :: Type -> Type -> Type) where
- applyPrimFL :: ApplyMonad (ApplyState prim) m => FL prim wX wY -> m ()
- class (Commute prim, Eq2 prim, Invert prim) => PrimCoalesce (prim :: Type -> Type -> Type) where
- tryToShrink :: FL prim wX wY -> Maybe (FL prim wX wY)
- sortCoalesceFL :: FL prim wX wY -> FL prim wX wY
- primCoalesce :: prim wX wY -> prim wY wZ -> Maybe (prim wX wZ)
- isIdentity :: prim wX wY -> EqCheck wX wY
- comparePrim :: prim wA wB -> prim wC wD -> Ordering
- class PrimConstruct (prim :: Type -> Type -> Type) 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 (ObjectIdOfPatch prim) wX wY -> prim wX wY
- class PrimDetails (prim :: Type -> Type -> Type) where
- summarizePrim :: prim wX wY -> [SummDetail]
- class PrimMangleUnravelled (prim :: Type -> Type -> Type) where
- mangleUnravelled :: Unravelled prim wX -> Maybe (Mangled prim wX)
- type PrimPatch (prim :: Type -> Type -> Type) = (Annotate prim, Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCoalesce prim, PrimDetails prim, PrimApply prim, PrimSift prim, PrimMangleUnravelled prim, ReadPatch prim, ShowPatch prim, ShowContextPatch prim, PatchListFormat prim)
- class PrimRead (prim :: Type -> Type -> Type) where
- readPrim :: FileNameFormat -> Parser (Sealed (prim wX))
- class PrimShow (prim :: Type -> Type -> Type) where
- showPrim :: FileNameFormat -> prim wA wB -> Doc
- showPrimWithContextAndApply :: ApplyMonad (ApplyState prim) m => FileNameFormat -> prim wA wB -> m Doc
- class PrimSift (prim :: Type -> Type -> Type) where
- primIsSiftable :: prim wX wY -> Bool
- type Mangled (prim :: Type -> Type -> Type) wX = Sealed (FL prim wX)
- type Unravelled (prim :: Type -> Type -> Type) wX = [Sealed (FL prim wX)]
- canonizeFL :: forall (prim :: Type -> Type -> Type) wX wY. (IsHunk prim, PrimCoalesce prim, PrimConstruct prim) => DiffAlgorithm -> FL prim wX wY -> FL prim wX wY
- coalesce :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY)
Documentation
class PrimApply (prim :: Type -> Type -> Type) where #
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 () # |
class (Commute prim, Eq2 prim, Invert prim) => PrimCoalesce (prim :: Type -> Type -> Type) where #
Methods
tryToShrink :: FL prim wX wY -> Maybe (FL prim wX wY) #
Try to shrink the input sequence by getting rid of self-cancellations
and identity patches or by coalescing patches. Also sort patches
according to some internally defined order (specific to the patch type)
as far as possible while respecting dependencies.
A result of Nothing
means that we could not shrink the input.
This method is included in the class for optimization. Instances are free
to use defaultTryToShrink
.
sortCoalesceFL :: FL prim wX wY -> FL prim wX wY #
This is similar to tryToShrink
but always gives back a result: if the
sequence could not be shrunk we merely give back a sorted version.
This method is included in the class for optimization. Instances are free
to use defaultSortCoalesceFL
.
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
isIdentity :: prim wX wY -> EqCheck wX wY #
Whether prim patch has no effect at all and thus can be eliminated as far as coalescing is concerned.
comparePrim :: prim wA wB -> prim wC wD -> Ordering #
Provide a total order between arbitrary patches that is consistent
with Eq2
:
unsafeCompare p q == IsEq <=> comparePrim p q == EQ
Instances
PrimCoalesce Prim # | |
Defined in Darcs.Patch.Prim.FileUUID.Coalesce | |
PrimCoalesce Prim # | |
Defined in Darcs.Patch.Prim.V1.Coalesce | |
PrimCoalesce Prim # | |
Defined in Darcs.Patch.V1.Prim | |
PrimCoalesce Prim # | |
Defined in Darcs.Patch.V2.Prim |
class PrimConstruct (prim :: Type -> Type -> Type) 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 (ObjectIdOfPatch prim) wX wY -> prim wX wY #
Instances
class PrimDetails (prim :: Type -> Type -> Type) 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] # |
class PrimMangleUnravelled (prim :: Type -> Type -> Type) 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 PrimPatch (prim :: Type -> Type -> Type) = (Annotate prim, Apply prim, CleanMerge prim, Commute prim, Invert prim, Eq2 prim, IsHunk prim, PatchInspect prim, RepairToFL prim, Show2 prim, PrimConstruct prim, PrimCoalesce prim, PrimDetails prim, PrimApply prim, PrimSift prim, PrimMangleUnravelled prim, ReadPatch prim, ShowPatch prim, ShowContextPatch prim, PatchListFormat prim) #
class PrimRead (prim :: Type -> Type -> Type) where #
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 |
class PrimShow (prim :: Type -> Type -> Type) where #
Methods
showPrim :: FileNameFormat -> prim wA wB -> Doc #
showPrimWithContextAndApply :: 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 # showPrimWithContextAndApply :: ApplyMonad (ApplyState Prim) m => FileNameFormat -> Prim wA wB -> m Doc # | |
(Apply Prim, ApplyState Prim ~ Tree, ObjectIdOfPatch Prim ~ AnchoredPath) => PrimShow Prim # | |
Defined in Darcs.Patch.Prim.V1.Show Methods showPrim :: FileNameFormat -> Prim wA wB -> Doc # showPrimWithContextAndApply :: ApplyMonad (ApplyState Prim) m => FileNameFormat -> Prim wA wB -> m Doc # |
class PrimSift (prim :: Type -> Type -> Type) where #
Prim patches that support "sifting". This is the process of eliminating changes from a sequence of prims that can be recovered by comparing states (normally the pristine and working states), except those that other changes depend on. In other words, changes to the content of (tracked) files. The implementation is allowed and expected to shrink and coalesce changes in the process.
Instances
PrimSift Prim # | |
Defined in Darcs.Patch.Prim.FileUUID.Coalesce Methods primIsSiftable :: Prim wX wY -> Bool # | |
PrimSift Prim # | |
Defined in Darcs.Patch.Prim.V1.Core Methods primIsSiftable :: Prim wX wY -> Bool # | |
PrimSift Prim # | |
Defined in Darcs.Patch.V1.Prim Methods primIsSiftable :: Prim wX wY -> Bool # | |
PrimSift Prim # | |
Defined in Darcs.Patch.V2.Prim Methods primIsSiftable :: Prim wX wY -> Bool # |
type Mangled (prim :: Type -> Type -> Type) wX = Sealed (FL prim wX) #
Result of mangling a single Unravelled.
type Unravelled (prim :: Type -> Type -> Type) wX = [Sealed (FL prim wX)] #
A list of conflicting alternatives. They form a connected component of the conflict graph i.e. one transitive conflict.
canonizeFL :: forall (prim :: Type -> Type -> Type) wX wY. (IsHunk prim, PrimCoalesce prim, PrimConstruct prim) => DiffAlgorithm -> FL prim wX wY -> FL prim wX wY #
Put 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.
XXX Why not? How does it differ? The implementation for Prim.V1 does sortCoalesceFL and then invokes the diff algorithm for each hunk. How can that be any different to applying the sequence and then taking the diff? Is this merely because diff does not sort by file path?
Besides, diff and apply must be inverses in the sense that for any two states {start, end}, we have
diff start (apply (diff start end)) == end
coalesce :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY) #
Either primCoalesce
or cancel inverses.
primCoalesce (p :> q) == Just r => apply r = apply p >> apply q