diff options
Diffstat (limited to 'haskell/examples/testdiff.hs')
-rw-r--r-- | haskell/examples/testdiff.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/haskell/examples/testdiff.hs b/haskell/examples/testdiff.hs new file mode 100644 index 0000000..7e20dc5 --- /dev/null +++ b/haskell/examples/testdiff.hs | |||
@@ -0,0 +1,31 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | |||
3 | import qualified Data.ByteString.Lazy as L | ||
4 | import Data.VCDIFF | ||
5 | import Text.XXD | ||
6 | |||
7 | source :: L.ByteString | ||
8 | source = "It could be said that Joe was here. I don't know what to do about it." | ||
9 | |||
10 | patched :: L.ByteString | ||
11 | patched = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." | ||
12 | |||
13 | delta :: Result VCDIFF | ||
14 | delta = computeDiff defaultConfig source patched | ||
15 | |||
16 | main = do | ||
17 | mapM_ putStrLn $ xxd2 0 (L.toStrict source) | ||
18 | putStrLn "" | ||
19 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched) | ||
20 | putStrLn "" | ||
21 | case delta of | ||
22 | Result δ@(VCDIFF d) me -> do | ||
23 | -- mapM_ (mapM_ putStrLn . xxd2 0) (chunksOf 16 d) | ||
24 | mapM_ putStrLn $ xxd2 0 (L.toStrict d) | ||
25 | print me | ||
26 | putStrLn "" | ||
27 | let Result patched' pe = applyPatch defaultConfig source δ | ||
28 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched') | ||
29 | print pe | ||
30 | print ("source",source) | ||
31 | print ("patched",patched) | ||