-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple, fast binary diff/patch -- -- Compute a patch between two ByteStrings which can later be applied to -- the first to produce the second. This can be used to save bandwidth -- and disk space when many strings differing by a small number of bytes -- need to be transmitted or stored. -- -- The underlying implementation is written in C, and can also be found -- at http://ccan.ozlabs.org/info/bdelta.html. -- -- Currently, a patch does not save any space when two strings differ by -- more than 1000 bytes. This arbitrary limit serves to keep applications -- from spiking in memory and CPU usage, as the algorithm uses quadratic -- space and time with respect to the length of the patch. A better -- algorithm may be introduced in a future version of bdelta. @package bdelta @version 0.1 -- | Binary diff/patch for ByteStrings. -- -- The diff function takes two ByteStrings, and produces a -- "patch" that can later be applied with the patch function to -- the first string to produce the second string. It exploits common -- subsequences between the two strings, and can be used to save -- bandwidth and disk space when many strings differing by a small number -- of bytes need to be transmitted or stored. -- -- Deltas produced by this version of the library can be applied using -- current or future versions, but may not be compatible with past -- versions. -- -- bdelta implements the algorithm described in An O(ND) Difference -- Algorithm and Its Variations by Eugene W. Myers. Because its -- memory usage and expected running time are O(N + D^2), it works well -- only when the strings differ by a small number of bytes. This -- implementation stops trying when the strings differ by more than 1000 -- bytes, and falls back to producing a patch that simply emits the new -- string. -- -- Thus, bdelta does not save any space when given two strings that -- differ by more than 1000 bytes. This may be improved in a future -- version of the library. module Data.BDelta -- | Compute a delta between two ByteStrings. -- --
-- patch old (diff old new) == Right new --diff :: ByteString -> ByteString -> ByteString -- | Apply a delta produced by diff. -- -- If the patch cannot be applied, this function returns Left -- errmsg, where errmsg is a string describing the error. patch :: ByteString -> ByteString -> Either String ByteString