{-# LANGUAGE OverloadedStrings #-} import qualified Data.ByteString.Lazy as L import Data.VCDIFF import Text.XXD source :: L.ByteString source = "It could be said that Joe was here. I don't know what to do about it." source2 :: L.ByteString source2 = "It could be said that Joe was not here. I don't know what to do about it." target :: L.ByteString target = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." delta :: Result VCDIFF delta = computeDiff defaultConfig source target delta2 :: Result VCDIFF delta2 = computeDiff defaultConfig source target delta3 :: Result VCDIFF delta3 = computeDiff defaultConfig { flags = XD3_ADLER32 } source target delta4 :: Result VCDIFF delta4 = computeDiff defaultConfig { flags = XD3_ADLER32 } source target dump title bs kont = do putStrLn title mapM_ putStrLn $ xxd2 0 (L.toStrict bs) kont main = do dump "source" source $ putStrLn "" dump "target" target $ putStrLn "" go source "default" delta go source "default" delta2 go source "XD3_ADLER32" delta3 go source "XD3_ADLER32" delta4 go source2 "default" delta go source2 "default" delta2 go source2 "XD3_ADLER32" delta3 go source2 "XD3_ADLER32" delta4 go source flgs delta = do putStrLn "" case delta of Result δ me -> do let dif = encodeVCDIFF δ dump ("diff("++flgs++ ")") dif $ print me >> putStrLn "" let Result patched pe = applyPatch defaultConfig source δ dump ("patched("++flgs++")") patched $ print pe