filediff-1.0.0.5: Diffing and patching module

Safe HaskellNone
LanguageHaskell2010

Filediff

Contents

Description

The module exposing the functionality of this package

Synopsis

lists

diffLists :: forall a. Eq a => [a] -> [a] -> ListDiff a Source

Computes the minimal number of additions and deletions needed to transform the first parameter into the second.

λ diffLists "abcdefg" "wabxyze"
ListDiff {dels = [(2,'c'),(3,'d'),(5,'f'),(6,'g')], adds = [(0,'w'),(3,'x'),(4,'y'),(5,'z')]}

applyListDiff :: forall a. Eq a => ListDiff a -> [a] -> [a] Source

λ diffLists "abcdefg" "wabxyze"
ListDiff {dels = [(2,'c'),(3,'d'),(5,'f'),(6,'g')], adds = [(0,'w'),(3,'x'),(4,'y'),(5,'z')]}
λ applyListDiff it "abcdefg"
"wabxyze"

Throws an exception if the diff can't be applied.

files

diffFiles :: FilePath -> FilePath -> IO Filediff Source

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.

applyToFile :: Filediff -> FilePath -> IO [Line] Source

O(n). Apply a diff to a file. Throws an exception if the application fails.

directories

diffDirectories :: FilePath -> FilePath -> IO Diff Source

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.

diffDirectoriesWithIgnoredSubdirs :: FilePath -> FilePath -> [FilePath] -> [FilePath] -> IO Diff Source

Diff two directories, ignoring some subdirectories. The first `[FilePath]` parameter refers to the first FilePath parameter, and same for the second, respectively.

applyToDirectory :: Diff -> FilePath -> IO () Source

Applies a Diff to a directory. Throws an exception if the application fails.