-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Diff and patch module -- @package filediff @version 0.1.0.0 -- | Diffing algorithms (all exposed functions are pure) module Filediff.Sequence -- | Diff between two sequences. fst represents the indices | at -- which to delete, and snd 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 (Eq a, MemoTable a) => Monoid (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 -> SeqDiff Line -> Filediff base :: Filediff -> FilePath comp :: Filediff -> FilePath linediff :: Filediff -> SeqDiff Line -- | A data type for differences between directories data Diff Diff :: [Filediff] -> Diff filediffs :: Diff -> [Filediff] -- | Data type for a line type Line = Text -- | Basic error type type Error = String instance Eq Filediff instance Show Filediff instance Show Diff instance Monoid Diff instance MemoTable Text instance Eq Diff instance Monoid Filediff -- | 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 ()