summaryrefslogtreecommitdiff
path: root/examples/testdiff.hs
blob: 4ed7dd4457048c6358b5c12085005e2ed1ad3dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Lazy as L
import Data.XDelta
import Text.XXD

source :: L.ByteString
source = "It could be said that Joe was here. I don't know what to do about it."

patched :: L.ByteString
patched = "It could be said that Joe, the magnificent, was here.  I don't know what to do about it."

delta :: XDeltaFailable XDelta
delta = computeDiff defaultConfig source patched

main = do
    mapM_ putStrLn $ xxd2 0 (L.toStrict source)
    putStrLn ""
    mapM_ putStrLn $ xxd2 0 (L.toStrict patched)
    putStrLn ""
    case delta of
        XSuccess (XDelta d) -> mapM_ putStrLn $ xxd2 0 (L.toChunks d !! 0)
        _                   -> print delta