packages feed

filediff 1.0.0.1 → 1.0.0.2

raw patch · 3 files changed

+30/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.md view
@@ -2,6 +2,8 @@  `filediff` is a Haskell library for creating diffs, and applying diffs to files and directories. +[![Build Status](https://travis-ci.org/bgwines/filediff.svg?branch=master)](https://travis-ci.org/bgwines/filediff) [![Hackage](https://img.shields.io/hackage/v/filediff.svg)](https://hackage.haskell.org/package/filediff) [![Coverage Status](https://coveralls.io/repos/bgwines/filediff/badge.svg?branch=master)](https://coveralls.io/r/bgwines/filediff?branch=master)+ ## Testing      cabal configure --enable tests && build && cabal test@@ -9,6 +11,4 @@ ## Found an issue?  Don't hesitate to let me know / issue a PR!--[![Build Status](https://travis-ci.org/bgwines/filediff.svg?branch=master)](https://travis-ci.org/bgwines/filediff) 
filediff.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                filediff-version:             1.0.0.1+version:             1.0.0.2 synopsis:            Diffing and patching module description:         `filediff` is a Haskell library for creating diffs, and applying diffs to files and directories. homepage:            https://github.com/bgwines/filediff@@ -32,4 +32,4 @@     main-is:    Tests/test-filediff.hs     build-depends: base >=4.7 && <4.8, tasty, tasty-hunit, mtl, time, directory, either, transformers, filediff, text     default-language:    Haskell2010-    --GHC-Options:      -fhpc -hpcdir dist/hpc/filediff-1.0+    GHC-Options:      -fhpc -hpcdir dist/hpc/mix/test-filediff
src/Filediff.hs view
@@ -223,7 +223,7 @@     (getProgressiveIndicesToAdd common b)     where         common :: [a]-        common = longestCommonSubsequence a b+        common = longestCommonSubsequenceWrapper a b          -- | > λ add         --   > [(0,"w"),(3,"x"),(4,"y")]@@ -260,6 +260,31 @@                 else d : insertAtProgressiveIndices' (succ curr) src dest'  -- all functions below are not exposed++-- don't hit the memotable if not necessary+longestCommonSubsequenceWrapper :: forall a. (MemoTable a, Eq a) => [a] -> [a] -> [a]+longestCommonSubsequenceWrapper xs ys =+    if xs == ys+        then xs -- (WLOG) don't want to return xs ++ xs+        else commonPrefix ++ longestCommonSubsequence xs' ys' ++ commonSuffix+    where+        commonPrefix :: [a]+        commonPrefix = getCommonPrefix xs ys++        commonSuffix :: [a]+        commonSuffix = reverse (getCommonPrefix (reverse xs) (reverse ys))++        getCommonPrefix :: [a] -> [a] -> [a]+        getCommonPrefix as bs = map fst . takeWhile (uncurry (==)) $ zip as bs++        getMiddle :: [a] -> [a]+        getMiddle elems = take (length elems - length commonPrefix - length commonSuffix) . drop (length commonPrefix) $ elems++        xs' :: [a]+        xs' = getMiddle xs++        ys' :: [a]+        ys' = getMiddle ys  -- optimization: hash lines -- | Compute the longest common (potentially noncontiguous) subsequence