-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Diffing of (expression) trees.
--   
--   Common diff algorithm works on list structures:
--   
--   <pre>
--   diff :: Eq a =&gt; [a] -&gt; [a] -&gt; [Edit a]
--   </pre>
--   
--   This package works on trees.
--   
--   <pre>
--   treeDiff :: Eq a =&gt; Tree a -&gt; Tree a -&gt; Edit (EditTree a)
--   </pre>
--   
--   This package also provides a way to diff arbitrary ADTs, using
--   <tt>Generics</tt>-derivable helpers.
--   
--   This package differs from <a>gdiff</a>, in a two ways:
--   <tt>tree-diff</tt> doesn't have patch function, and the "edit-script"
--   is a tree itself, which is useful for pretty-printing.
--   
--   <pre>
--   &gt;&gt;&gt; prettyEditExpr $ ediff (Foo 42 [True, False] "old") (Foo 42 [False, False, True] "new")
--   Foo
--   fooBool = [-True, +False, False, +True],
--   fooInt = 42,
--   fooString = -"old" +"new"
--   </pre>
@package tree-diff
@version 0.0.1


-- | A list diff.
module Data.TreeDiff.List

-- | List difference.
--   
--   <pre>
--   &gt;&gt;&gt; diffBy (==) "hello" "world"
--   [Swp 'h' 'w',Swp 'e' 'o',Swp 'l' 'r',Cpy 'l',Swp 'o' 'd']
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; diffBy (==) "kitten" "sitting"
--   [Swp 'k' 's',Cpy 'i',Cpy 't',Cpy 't',Swp 'e' 'i',Cpy 'n',Ins 'g']
--   </pre>
--   
--   <pre>
--   \xs ys -&gt; length (diffBy (==) xs ys) &gt;= max (length xs) (length (ys :: String))
--   </pre>
--   
--   <pre>
--   \xs ys -&gt; length (diffBy (==) xs ys) &lt;= length xs + length (ys :: String)
--   </pre>
--   
--   <i>Note:</i> currently this has O(n*m) memory requirements, for the
--   sake of more obviously correct implementation.
diffBy :: forall a. (a -> a -> Bool) -> [a] -> [a] -> [Edit a]

-- | List edit operations
--   
--   The <a>Swp</a> constructor is redundant, but it let us spot a
--   recursion point when performing tree diffs.
data Edit a

-- | insert
Ins :: a -> Edit a

-- | delete
Del :: a -> Edit a

-- | copy unchanged
Cpy :: a -> Edit a

-- | swap, i.e. delete + insert
Swp :: a -> a -> Edit a
instance GHC.Show.Show a => GHC.Show.Show (Data.TreeDiff.List.Edit a)


-- | This module uses <a>Expr</a> for richer diffs than based on
--   <tt>Tree</tt>.
module Data.TreeDiff.Expr

-- | A untyped Haskell-like expression.
--   
--   Having richer structure than just <tt>Tree</tt> allows to have richer
--   diffs.
data Expr

-- | application
App :: ConstructorName -> [Expr] -> Expr

-- | record constructor
Rec :: ConstructorName -> (Map FieldName Expr) -> Expr

-- | list constructor
Lst :: [Expr] -> Expr

-- | Constructor name is a string
type ConstructorName = String

-- | Record field name is a string too.
type FieldName = String

-- | Type used in the result of <tt>ediff</tt>.
data EditExpr
EditApp :: ConstructorName -> [Edit EditExpr] -> EditExpr
EditRec :: ConstructorName -> (Map FieldName (Edit EditExpr)) -> EditExpr
EditLst :: [Edit EditExpr] -> EditExpr

-- | unchanged tree
EditExp :: Expr -> EditExpr

-- | List edit operations
--   
--   The <a>Swp</a> constructor is redundant, but it let us spot a
--   recursion point when performing tree diffs.
data Edit a

-- | insert
Ins :: a -> Edit a

-- | delete
Del :: a -> Edit a

-- | copy unchanged
Cpy :: a -> Edit a

-- | swap, i.e. delete + insert
Swp :: a -> a -> Edit a

-- | Diff two <a>Expr</a>.
--   
--   For examples see <tt>ediff</tt> in <a>Data.TreeDiff.Class</a>.
exprDiff :: Expr -> Expr -> Edit EditExpr
instance GHC.Show.Show Data.TreeDiff.Expr.EditExpr
instance GHC.Show.Show Data.TreeDiff.Expr.Expr
instance GHC.Classes.Eq Data.TreeDiff.Expr.Expr
instance Test.QuickCheck.Arbitrary.Arbitrary Data.TreeDiff.Expr.Expr


-- | A <a>ToExpr</a> class.
module Data.TreeDiff.Class

-- | Difference between two <a>ToExpr</a> values.
--   
--   <pre>
--   &gt;&gt;&gt; let x = (1, Just 2) :: (Int, Maybe Int)
--   
--   &gt;&gt;&gt; let y = (1, Nothing)
--   
--   &gt;&gt;&gt; prettyEditExpr (ediff x y)
--   _×_ 1 -(Just 2) +Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; data Foo = Foo { fooInt :: Either Char Int, fooBool :: [Maybe Bool], fooString :: String } deriving (Eq, Generic)
--   
--   &gt;&gt;&gt; instance ToExpr Foo
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; prettyEditExpr $ ediff (Foo (Right 2) [Just True] "fo") (Foo (Right 3) [Just True] "fo")
--   Foo {fooBool = [Just True], fooInt = Right -2 +3, fooString = "fo"}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; prettyEditExpr $ ediff (Foo (Right 42) [Just True, Just False] "old") (Foo (Right 42) [Nothing, Just False, Just True] "new")
--   Foo
--     {fooBool = [-Just True, +Nothing, Just False, +Just True],
--      fooInt = Right 42,
--      fooString = -"old" +"new"}
--   </pre>
ediff :: ToExpr a => a -> a -> Edit EditExpr

-- | Compare different types.
--   
--   <i>Note:</i> Use with care as you can end up comparing apples with
--   oranges.
--   
--   <pre>
--   &gt;&gt;&gt; prettyEditExpr $ ediff' ["foo", "bar"] [Just "foo", Nothing]
--   [-"foo", +Just "foo", -"bar", +Nothing]
--   </pre>
ediff' :: (ToExpr a, ToExpr b) => a -> b -> Edit EditExpr

-- | <a>toExpr</a> converts a Haskell value into untyped Haskell-like
--   syntax tree, <a>Expr</a>.
--   
--   <pre>
--   &gt;&gt;&gt; toExpr ((1, Just 2) :: (Int, Maybe Int))
--   App "_\215_" [App "1" [],App "Just" [App "2" []]]
--   </pre>
class ToExpr a
toExpr :: ToExpr a => a -> Expr
toExpr :: (ToExpr a, Generic a, All2 ToExpr (GCode a), GFrom a, GDatatypeInfo a) => a -> Expr
listToExpr :: ToExpr a => [a] -> Expr

-- | An alternative implementation for literal types. We use <a>show</a>
--   representation of them.
defaultExprViaShow :: Show a => a -> Expr

-- | <pre>
--   &gt;&gt;&gt; prettyExpr $ sopToExpr (gdatatypeInfo (Proxy :: Proxy String)) (gfrom "foo")
--   _:_ 'f' "oo"
--   </pre>
sopToExpr :: (All2 ToExpr xss) => DatatypeInfo xss -> SOP I xss -> Expr
instance Data.TreeDiff.Class.ToExpr Data.TreeDiff.Expr.Expr
instance Data.TreeDiff.Class.ToExpr ()
instance Data.TreeDiff.Class.ToExpr GHC.Types.Bool
instance Data.TreeDiff.Class.ToExpr GHC.Types.Ordering
instance Data.TreeDiff.Class.ToExpr GHC.Integer.Type.Integer
instance Data.TreeDiff.Class.ToExpr GHC.Natural.Natural
instance Data.TreeDiff.Class.ToExpr GHC.Types.Float
instance Data.TreeDiff.Class.ToExpr GHC.Types.Double
instance Data.TreeDiff.Class.ToExpr GHC.Types.Int
instance Data.TreeDiff.Class.ToExpr GHC.Int.Int8
instance Data.TreeDiff.Class.ToExpr GHC.Int.Int16
instance Data.TreeDiff.Class.ToExpr GHC.Int.Int32
instance Data.TreeDiff.Class.ToExpr GHC.Int.Int64
instance Data.TreeDiff.Class.ToExpr GHC.Types.Word
instance Data.TreeDiff.Class.ToExpr GHC.Word.Word8
instance Data.TreeDiff.Class.ToExpr GHC.Word.Word16
instance Data.TreeDiff.Class.ToExpr GHC.Word.Word32
instance Data.TreeDiff.Class.ToExpr GHC.Word.Word64
instance Data.TreeDiff.Class.ToExpr (Data.Proxy.Proxy a)
instance Data.TreeDiff.Class.ToExpr GHC.Types.Char
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (GHC.Base.Maybe a)
instance (Data.TreeDiff.Class.ToExpr a, Data.TreeDiff.Class.ToExpr b) => Data.TreeDiff.Class.ToExpr (Data.Either.Either a b)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr [a]
instance (Data.TreeDiff.Class.ToExpr a, Data.TreeDiff.Class.ToExpr b) => Data.TreeDiff.Class.ToExpr (a, b)
instance (Data.TreeDiff.Class.ToExpr a, Data.TreeDiff.Class.ToExpr b, Data.TreeDiff.Class.ToExpr c) => Data.TreeDiff.Class.ToExpr (a, b, c)
instance (Data.TreeDiff.Class.ToExpr a, Data.TreeDiff.Class.ToExpr b, Data.TreeDiff.Class.ToExpr c, Data.TreeDiff.Class.ToExpr d) => Data.TreeDiff.Class.ToExpr (a, b, c, d)
instance (Data.TreeDiff.Class.ToExpr a, Data.TreeDiff.Class.ToExpr b, Data.TreeDiff.Class.ToExpr c, Data.TreeDiff.Class.ToExpr d, Data.TreeDiff.Class.ToExpr e) => Data.TreeDiff.Class.ToExpr (a, b, c, d, e)
instance (Data.TreeDiff.Class.ToExpr a, GHC.Real.Integral a) => Data.TreeDiff.Class.ToExpr (GHC.Real.Ratio a)
instance Data.Fixed.HasResolution a => Data.TreeDiff.Class.ToExpr (Data.Fixed.Fixed a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Functor.Identity.Identity a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Functor.Const.Const a b)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Control.Applicative.ZipList a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.List.NonEmpty.NonEmpty a)
instance Data.TreeDiff.Class.ToExpr Data.Void.Void
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Monoid.Dual a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Monoid.Sum a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Monoid.Product a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Monoid.First a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Monoid.Last a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Semigroup.Option a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Semigroup.Min a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Semigroup.Max a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Semigroup.First a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Semigroup.Last a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Tree.Tree a)
instance (Data.TreeDiff.Class.ToExpr k, Data.TreeDiff.Class.ToExpr v) => Data.TreeDiff.Class.ToExpr (Data.Map.Internal.Map k v)
instance Data.TreeDiff.Class.ToExpr k => Data.TreeDiff.Class.ToExpr (Data.Set.Internal.Set k)
instance Data.TreeDiff.Class.ToExpr v => Data.TreeDiff.Class.ToExpr (Data.IntMap.Internal.IntMap v)
instance Data.TreeDiff.Class.ToExpr Data.IntSet.Internal.IntSet
instance Data.TreeDiff.Class.ToExpr v => Data.TreeDiff.Class.ToExpr (Data.Sequence.Internal.Seq v)
instance Data.TreeDiff.Class.ToExpr Data.Text.Internal.Lazy.Text
instance Data.TreeDiff.Class.ToExpr Data.Text.Internal.Text
instance Data.TreeDiff.Class.ToExpr Data.Time.Calendar.Days.Day
instance Data.TreeDiff.Class.ToExpr Data.Time.Clock.Internal.UTCTime.UTCTime
instance Data.TreeDiff.Class.ToExpr Data.ByteString.Lazy.Internal.ByteString
instance Data.TreeDiff.Class.ToExpr Data.ByteString.Internal.ByteString
instance Data.TreeDiff.Class.ToExpr Data.Scientific.Scientific
instance Data.TreeDiff.Class.ToExpr Data.UUID.Types.Internal.UUID
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Vector.Vector a)
instance (Data.TreeDiff.Class.ToExpr a, Data.Vector.Unboxed.Base.Unbox a) => Data.TreeDiff.Class.ToExpr (Data.Vector.Unboxed.Base.Vector a)
instance (Data.TreeDiff.Class.ToExpr a, Foreign.Storable.Storable a) => Data.TreeDiff.Class.ToExpr (Data.Vector.Storable.Vector a)
instance (Data.TreeDiff.Class.ToExpr a, Data.Primitive.Types.Prim a) => Data.TreeDiff.Class.ToExpr (Data.Vector.Primitive.Vector a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Tagged.Tagged t a)
instance Data.TreeDiff.Class.ToExpr a => Data.TreeDiff.Class.ToExpr (Data.Hashable.Class.Hashed a)
instance (Data.TreeDiff.Class.ToExpr k, Data.TreeDiff.Class.ToExpr v) => Data.TreeDiff.Class.ToExpr (Data.HashMap.Base.HashMap k v)
instance Data.TreeDiff.Class.ToExpr k => Data.TreeDiff.Class.ToExpr (Data.HashSet.HashSet k)
instance Data.TreeDiff.Class.ToExpr Data.Aeson.Types.Internal.Value


-- | Utilities to parse <a>Expr</a>.
--   
--   <i>Note:</i> we don't parse diffs.
module Data.TreeDiff.Parser

-- | Parsers for <a>Expr</a> using <tt>parsers</tt> type-classes.
--   
--   You can use this with your parser-combinator library of choice:
--   <tt>parsec</tt>, <tt>attoparsec</tt>, <tt>trifecta</tt>...
exprParser :: (Monad m, TokenParsing m) => m Expr


-- | Utilities to pretty print <a>Expr</a> and <a>EditExpr</a>
module Data.TreeDiff.Pretty

-- | Because we don't want to commit to single pretty printing library, we
--   use explicit dictionary.
data Pretty doc
Pretty :: (ConstructorName -> doc) -> ([(FieldName, doc)] -> doc) -> ([doc] -> doc) -> (doc -> doc) -> (doc -> doc) -> (doc -> doc) -> ([doc] -> doc) -> (doc -> doc) -> (doc -> doc -> doc) -> Pretty doc
[ppCon] :: Pretty doc -> ConstructorName -> doc
[ppRec] :: Pretty doc -> [(FieldName, doc)] -> doc
[ppLst] :: Pretty doc -> [doc] -> doc
[ppCpy] :: Pretty doc -> doc -> doc
[ppIns] :: Pretty doc -> doc -> doc
[ppDel] :: Pretty doc -> doc -> doc
[ppSep] :: Pretty doc -> [doc] -> doc
[ppParens] :: Pretty doc -> doc -> doc
[ppHang] :: Pretty doc -> doc -> doc -> doc

-- | Pretty print an <a>Expr</a> using explicit pretty-printing dictionary.
ppExpr :: Pretty doc -> Expr -> doc

-- | Pretty print an <tt><a>Edit</a> <a>EditExpr</a></tt> using explicit
--   pretty-printing dictionary.
ppEditExpr :: Pretty doc -> Edit EditExpr -> doc

-- | <a>Pretty</a> via <tt>pretty</tt> library.
prettyPretty :: Pretty Doc

-- | Pretty print <a>Expr</a> using <tt>pretty</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; prettyExpr $ Rec "ex" (Map.fromList [("[]", App "bar" [])])
--   ex {`[]` = bar}
--   </pre>
prettyExpr :: Expr -> Doc

-- | Pretty print <tt><a>Edit</a> <a>EditExpr</a></tt> using
--   <tt>pretty</tt>.
prettyEditExpr :: Edit EditExpr -> Doc

-- | <a>Pretty</a> via <tt>ansi-wl-pprint</tt> library (with colors).
ansiWlPretty :: Pretty Doc

-- | Pretty print <a>Expr</a> using <tt>ansi-wl-pprint</tt>.
ansiWlExpr :: Expr -> Doc

-- | Pretty print <tt><a>Edit</a> <a>EditExpr</a></tt> using
--   <tt>ansi-wl-pprint</tt>.
ansiWlEditExpr :: Edit EditExpr -> Doc

-- | Like <a>ansiWlPretty</a> but color the background.
ansiWlBgPretty :: Pretty Doc

-- | Pretty print <a>Expr</a> using <tt>ansi-wl-pprint</tt>.
ansiWlBgExpr :: Expr -> Doc

-- | Pretty print <tt><a>Edit</a> <a>EditExpr</a></tt> using
--   <tt>ansi-wl-pprint</tt>.
ansiWlBgEditExpr :: Edit EditExpr -> Doc

-- | Escape field or constructor name
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName "Foo"
--   Foo
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName "_×_"
--   _×_
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName "-3"
--   `-3`
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName "kebab-case"
--   kebab-case
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName "inner space"
--   `inner space`
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName $ show "looks like a string"
--   "looks like a string"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName $ show "tricky" ++ "   "
--   `"tricky"   `
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName "[]"
--   `[]`
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; putStrLn $ escapeName "_,_"
--   `_,_`
--   </pre>
escapeName :: String -> String


-- | Diffing of (expression) trees.
--   
--   Diffing arbitrary Haskell data. First we convert values to untyped
--   haskell-like expression <a>Expr</a> using generically derivable
--   <a>ToExpr</a> class. Then we can diff two <a>Expr</a> values. The
--   conversion and diffing is done by <a>ediff</a> function. See type and
--   function haddocks for an examples.
--   
--   Interesting modules:
--   
--   <ul>
--   <li><a>Data.TreeDiff.Class</a> for a <a>ToExpr</a> class and
--   <a>ediff</a> utility.</li>
--   <li><a>Data.TreeDiff.Golden</a> for golden tests helper</li>
--   <li><a>Data.TreeDiff.QuickCheck</a> for QuickCheck helper</li>
--   </ul>
module Data.TreeDiff


-- | "Golden tests" using <a>ediff</a> comparison.
module Data.TreeDiff.Golden

-- | Make a golden tests.
--   
--   <a>ediffGolden</a> is testing framework agnostic, thus the test
--   framework looks intimdating.
--   
--   An example using <tt>tasty-golden</tt>, <tt>goldenTest</tt> is
--   imported from <a>Test.Tasty.Golden.Advanced</a>
--   
--   <pre>
--   exTest :: TestTree
--   exTest = <a>ediffGolden</a> goldenTest "golden test" "fixtures/ex.expr" $
--      action constructing actual value
--   </pre>
--   
--   The <a>ediffGolden</a> will read an <a>Expr</a> from provided path to
--   golden file, and compare it with a <a>toExpr</a> of a result. If
--   values differ, the diff of two will be printed.
--   
--   See
--   <a>https://github.com/phadej/tree-diff/blob/master/tests/Tests.hs</a>
--   for a proper example.
ediffGolden :: (Eq a, ToExpr a) => (testName -> IO Expr -> IO Expr -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree) -> testName -> FilePath -> IO a -> testTree


-- | <tt>QuickCheck</tt> related utilities.
module Data.TreeDiff.QuickCheck

-- | A variant of <tt>===</tt>, which outputs a diff when values are
--   inequal.
ediffEq :: (Eq a, ToExpr a) => a -> a -> Property


-- | Tree diffing working on <tt>containers</tt> <a>Tree</a>.
module Data.TreeDiff.Tree

-- | A breadth-traversal diff.
--   
--   It's different from <tt>gdiff</tt>, as it doesn't produce a flat edit
--   script, but edit script iself is a tree. This makes visualising the
--   diff much simpler.
--   
--   <h4>Examples</h4>
--   
--   Let's start from simple tree. We pretty print them as s-expressions.
--   
--   <pre>
--   &gt;&gt;&gt; let x = Node 'a' [Node 'b' [], Node 'c' [return 'd', return 'e'], Node 'f' []]
--   
--   &gt;&gt;&gt; ppTree PP.char x
--   (a b (c d e) f)
--   </pre>
--   
--   If we modify an argument in a tree, we'll notice it's changed:
--   
--   <pre>
--   &gt;&gt;&gt; let y = Node 'a' [Node 'b' [], Node 'c' [return 'x', return 'e'], Node 'f' []]
--   
--   &gt;&gt;&gt; ppTree PP.char y
--   (a b (c x e) f)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ppEditTree PP.char (treeDiff x y)
--   (a b (c -d +x e) f)
--   </pre>
--   
--   If we modify a constructor, the whole sub-trees is replaced, though
--   there might be common subtrees.
--   
--   <pre>
--   &gt;&gt;&gt; let z = Node 'a' [Node 'b' [], Node 'd' [], Node 'f' []]
--   
--   &gt;&gt;&gt; ppTree PP.char z
--   (a b d f)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ppEditTree PP.char (treeDiff x z)
--   (a b -(c d e) +d f)
--   </pre>
--   
--   If we add arguments, they are spotted too:
--   
--   <pre>
--   &gt;&gt;&gt; let w = Node 'a' [Node 'b' [], Node 'c' [return 'd', return 'x', return 'e'], Node 'f' []]
--   
--   &gt;&gt;&gt; ppTree PP.char w
--   (a b (c d x e) f)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; ppEditTree PP.char (treeDiff x w)
--   (a b (c d +x e) f)
--   </pre>
treeDiff :: Eq a => Tree a -> Tree a -> Edit (EditTree a)

-- | Type used in the result of <a>treeDiff</a>.
--   
--   It's essentially a <a>Tree</a>, but the forest list is changed from
--   <tt>[tree a]</tt> to <tt>[<a>Edit</a> (tree a)]</tt>. This highlights
--   that <a>treeDiff</a> performs a list diff on each tree level.
data EditTree a
EditNode :: a -> [Edit (EditTree a)] -> EditTree a

-- | List edit operations
--   
--   The <a>Swp</a> constructor is redundant, but it let us spot a
--   recursion point when performing tree diffs.
data Edit a

-- | insert
Ins :: a -> Edit a

-- | delete
Del :: a -> Edit a

-- | copy unchanged
Cpy :: a -> Edit a

-- | swap, i.e. delete + insert
Swp :: a -> a -> Edit a
instance GHC.Show.Show a => GHC.Show.Show (Data.TreeDiff.Tree.EditTree a)
