-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Diffing and patching module -- -- filediff is a Haskell library for creating diffs, and applying -- diffs to files and directories. @package filediff @version 0.1.0.7 -- | 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 "base"
-- FilePath is the file chose state is being compared against, and
-- the "comp" FilePath is the file being compared (the "later" of
-- the two).
data Filediff
Filediff :: FilePath -> FilePath -> FileChange -> Filediff
base :: Filediff -> FilePath
comp :: Filediff -> FilePath
change :: Filediff -> FileChange
-- | A data type for differences between directories. filediffs
-- stores Filediffs whose filepaths are relative to directories
-- being diffed.
data Diff
Diff :: [Filediff] -> Diff
filediffs :: Diff -> [Filediff]
-- | The types and sets of changes possible between two files.
data FileChange
Del :: (SeqDiff Line) -> FileChange
Mod :: (SeqDiff Line) -> FileChange
Add :: (SeqDiff Line) -> FileChange
-- | Gets the SeqDiff stored in a FileChange.
seqDiff :: FileChange -> SeqDiff Line
-- | Whether a FileChange is a deletion or not.
isDel :: FileChange -> Bool
-- | Whether a FileChange is a modification or not.
isMod :: FileChange -> Bool
-- | Whether a FileChange is a addition or not.
isAdd :: FileChange -> Bool
-- | 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
-- | Statistics on diffs
module Filediff.Stats
-- | Number of files added, modified, or deleted in a diff.
numFilesAffected :: Diff -> Int
-- | Number of lines added in a diff.
numAddedLines :: Diff -> Int
-- | Number of lines deleted in a diff.
numDeletedLines :: Diff -> Int
-- | 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
-- | Diff two directories, ignoring some subdirectories. The first
-- `[FilePath]` parameter refers to the first FilePath parameter,
-- and same for the second, respectively.
diffDirectoriesWithIgnoredSubdirs :: FilePath -> FilePath -> [FilePath] -> [FilePath] -> IO Diff
-- | O(n). Apply a diff to a file. Throws an exception if the
-- application fails.
applyToFile :: Filediff -> FilePath -> IO [Line]
-- | Applies a Diff to a directory. Throws an exception if the
-- application fails.
applyToDirectory :: Diff -> FilePath -> IO ()