-- 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 1.0.0.2 -- | 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 :: (ListDiff Line) -> FileChange Mod :: (ListDiff Line) -> FileChange Add :: (ListDiff Line) -> FileChange -- | Diff between two lists. dels represents the indices at which to -- delete, and adds represents the indices and contents to add. data ListDiff a ListDiff :: [(Int, a)] -> [(Int, a)] -> ListDiff a dels :: ListDiff a -> [(Int, a)] adds :: ListDiff a -> [(Int, a)] -- | Gets the ListDiff stored in a FileChange. listDiff :: FileChange -> ListDiff 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 Show a => Show (ListDiff a) instance Eq a => Eq (ListDiff a) instance Generic (ListDiff a) 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 D1ListDiff instance Constructor C1_0ListDiff instance Selector S1_0_0ListDiff instance Selector S1_0_1ListDiff 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 instance (Eq a, Ord a, MemoTable a) => Monoid (ListDiff a) instance Default (ListDiff a) -- | 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 -- | A module for printing Filediff data types to the console. module Filediff.Printing -- | Prints a Diff. Prints with colors and some formatting. printDiff :: Diff -> IO () -- | Prints a Filediff. Prints with colors and some formatting. printFilediff :: Filediff -> IO () -- | Prints a ListDiff Line. Prints with colors and some -- formatting. printListdiff :: ListDiff Line -> IO () -- | The module exposing the functionality of this package module Filediff -- | 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')]}
--
diffLists :: (Eq a, MemoTable a) => [a] -> [a] -> ListDiff a
-- |
-- λ 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.
applyListDiff :: Eq a => ListDiff a -> [a] -> [a]
-- | 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
-- | O(n). Apply a diff to a file. Throws an exception if the
-- application fails.
applyToFile :: Filediff -> FilePath -> IO [Line]
-- | 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
-- | Applies a Diff to a directory. Throws an exception if the
-- application fails.
applyToDirectory :: Diff -> FilePath -> IO ()