summaryrefslogtreecommitdiff
path: root/haskell/examples/testdiff.hs
diff options
context:
space:
mode:
Diffstat (limited to 'haskell/examples/testdiff.hs')
-rw-r--r--haskell/examples/testdiff.hs30
1 files changed, 25 insertions, 5 deletions
diff --git a/haskell/examples/testdiff.hs b/haskell/examples/testdiff.hs
index 7e20dc5..3f6e3e2 100644
--- a/haskell/examples/testdiff.hs
+++ b/haskell/examples/testdiff.hs
@@ -10,22 +10,42 @@ source = "It could be said that Joe was here. I don't know what to do about it."
10patched :: L.ByteString 10patched :: L.ByteString
11patched = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." 11patched = "It could be said that Joe, the magnificent, was here. I don't know what to do about it."
12 12
13source2 :: L.ByteString
14source2 = "It could be said that Joe was absolutely here. I don't know what to do about it."
15
13delta :: Result VCDIFF 16delta :: Result VCDIFF
14delta = computeDiff defaultConfig source patched 17delta = computeDiff defaultConfig source patched
15 18
19delta2 :: Result VCDIFF
20delta2 = computeDiff defaultConfig { flags = XD3_ADLER32 } source patched
21
16main = do 22main = do
23 putStrLn "source"
17 mapM_ putStrLn $ xxd2 0 (L.toStrict source) 24 mapM_ putStrLn $ xxd2 0 (L.toStrict source)
18 putStrLn "" 25 putStrLn ""
26 putStrLn "target"
19 mapM_ putStrLn $ xxd2 0 (L.toStrict patched) 27 mapM_ putStrLn $ xxd2 0 (L.toStrict patched)
20 putStrLn "" 28 putStrLn ""
29 case delta2 of
30 Result δ me -> do
31 let d = encodeVCDIFF δ
32 putStrLn "diff(XD3_ADLER32)"
33 mapM_ putStrLn $ xxd2 0 (L.toStrict d)
34 print me
35 putStrLn ""
36 let Result patched' pe = applyPatch defaultConfig source2 δ
37 putStrLn "patched(XD3_ADLER32)"
38 mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched')
39 print pe
40 putStrLn ""
21 case delta of 41 case delta of
22 Result δ@(VCDIFF d) me -> do 42 Result δ me -> do
23 -- mapM_ (mapM_ putStrLn . xxd2 0) (chunksOf 16 d) 43 let d = encodeVCDIFF δ
44 putStrLn "diff(default)"
24 mapM_ putStrLn $ xxd2 0 (L.toStrict d) 45 mapM_ putStrLn $ xxd2 0 (L.toStrict d)
25 print me 46 print me
26 putStrLn "" 47 putStrLn ""
27 let Result patched' pe = applyPatch defaultConfig source δ 48 putStrLn "patched(default)"
49 let Result patched' pe = applyPatch defaultConfig source2 δ
28 mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched') 50 mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched')
29 print pe 51 print pe
30 print ("source",source)
31 print ("patched",patched)