-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Diffing and patching module -- @package filediff @version 0.1.0.3 -- | Diffing algorithms (all exposed functions are pure) module Filediff.Sequence -- | Diff between two lists. dels represents the indices at which to -- delete, and adds represents the indices and contents to add. data SeqDiff a SeqDiff :: [Int] -> [(Int, a)] -> SeqDiff a dels :: SeqDiff a -> [Int] adds :: SeqDiff a -> [(Int, a)] -- | returns (to delete, to add) -- --
-- diffSequences "abcdefg" "wabxyze" ---- -- SeqDiff {dels = [2,3,5,6], adds = -- [(0,w),(3,x),(4,y),(5,z)]} diffSequences :: (Eq a, MemoTable a) => [a] -> [a] -> SeqDiff a -- |
-- diffSequences "abcdefg" "wabxyze" ---- -- SeqDiff {dels = [2,3,5,6], adds = -- [(0,w),(3,x),(4,y),(5,z)]} -- --
-- applySequenceDiff it "abcdefg" ---- -- "wabxyze" applySequenceDiff :: Eq a => SeqDiff a -> [a] -> [a] instance Show a => Show (SeqDiff a) instance Eq a => Eq (SeqDiff a) instance Generic (SeqDiff a) instance Datatype D1SeqDiff instance Constructor C1_0SeqDiff instance Selector S1_0_0SeqDiff instance Selector S1_0_1SeqDiff instance (Eq a, MemoTable a) => Monoid (SeqDiff a) instance Default (SeqDiff a) -- | Data types used by Filediff module Filediff.Types -- | The basic data type for a difference between two files. The -- FilePath is the "base" file in the base-comp comparison, and is -- the file to which the patch will be applied. Deletions: a list of -- indices at which to remove elements. Additions: each line to add comes -- with the index at which it will eventually reside. data Filediff Filediff :: FilePath -> FilePath -> FileChange -> Filediff base :: Filediff -> FilePath comp :: Filediff -> FilePath change :: Filediff -> FileChange -- | A data type for differences between directories data Diff Diff :: [Filediff] -> Diff filediffs :: Diff -> [Filediff] -- | The types and sets of changes possible between two files. -- CompositionAddDel is hack to make mappend work -- properly :/ data FileChange Del :: (SeqDiff Line) -> FileChange Mod :: (SeqDiff Line) -> FileChange Add :: (SeqDiff Line) -> FileChange -- | Data type for a line type Line = Text -- | Basic error type type Error = String instance Eq FileChange instance Show FileChange instance Generic FileChange instance Eq Filediff instance Show Filediff instance Generic Filediff instance Show Diff instance Generic Diff instance Datatype D1FileChange instance Constructor C1_0FileChange instance Constructor C1_1FileChange instance Constructor C1_2FileChange instance Datatype D1Filediff instance Constructor C1_0Filediff instance Selector S1_0_0Filediff instance Selector S1_0_1Filediff instance Selector S1_0_2Filediff instance Datatype D1Diff instance Constructor C1_0Diff instance Selector S1_0_0Diff instance Monoid Diff instance MemoTable Text instance Default Diff instance Eq Diff instance Monoid Filediff instance Monoid FileChange -- | The module exposing the functionality of this package module Filediff -- | O(mn). Compute the difference between the two files (more -- specifically, the minimal number of changes to make to transform the -- file residing at the location specified by the first parameter into -- the second). Throws an exception if either or both of the parameters -- point to a directory, not a file. -- -- Files are allowed to not exist at either or both of the parameters. diffFiles :: FilePath -> FilePath -> IO Filediff -- | Compute the difference between the two directories (more specifically, -- the minimal number of changes to make to transform the directory -- residing at the location specified by the first parameter into the -- second). Throws an exception if either or both of the parameters point -- to a file, not a directory. diffDirectories :: FilePath -> FilePath -> IO Diff -- | O(n). Apply a diff to a directory or file applyToFile :: Filediff -> FilePath -> IO [Line] -- | True upon success; False upon failure applyToDirectory :: Diff -> FilePath -> IO ()