| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Generics.Diff.Special.Tree
Contents
Description
A worked example of implementing SpecialDiff (and thereby Diff) for Trees.
As with other 3rd-party types, there are different approaches we can take here. We'll show 2 of them:
- using
gspecialDiffNested; - using
SpecialDiffand a custom diff type.
Synopsis
- newtype CustomTree a = CustomTree (Tree a)
- newtype TreePath = TreePath [Int]
- data CustomTreeDiffError a
- renderTreePath :: TreePath -> Builder
Documentation
newtype CustomTree a Source #
A newtype wrapper around Tree to demonstrate one alternate way we could hand-write
a SpecialDiff instance.
Constructors
| CustomTree (Tree a) |
Instances
| Show a => Show (CustomTree a) Source # | |
Defined in Generics.Diff.Special.Tree Methods showsPrec :: Int -> CustomTree a -> ShowS # show :: CustomTree a -> String # showList :: [CustomTree a] -> ShowS # | |
| Diff a => Diff (CustomTree a) Source # | |
Defined in Generics.Diff.Special.Tree Methods diff :: CustomTree a -> CustomTree a -> DiffResult (CustomTree a) # diffList :: [CustomTree a] -> [CustomTree a] -> DiffResult [CustomTree a] # | |
| Diff a => SpecialDiff (CustomTree a) Source # | |
Defined in Generics.Diff.Special.Tree Associated Types type SpecialDiffError (CustomTree a) # Methods specialDiff :: CustomTree a -> CustomTree a -> Maybe (SpecialDiffError (CustomTree a)) # renderSpecialDiffError :: SpecialDiffError (CustomTree a) -> Doc # | |
| type SpecialDiffError (CustomTree a) Source # | |
Defined in Generics.Diff.Special.Tree | |
Where are we in the tree? Each element of the list says which child node we step to next.
data CustomTreeDiffError a Source #
A custom error type for CustomTree.
Constructors
| DiffAtNode TreePath (DiffError a) | |
| WrongLengthsOfChildren TreePath Int Int |
Instances
| Show (CustomTreeDiffError a) Source # | |
Defined in Generics.Diff.Special.Tree Methods showsPrec :: Int -> CustomTreeDiffError a -> ShowS # show :: CustomTreeDiffError a -> String # showList :: [CustomTreeDiffError a] -> ShowS # | |
| Eq (CustomTreeDiffError a) Source # | |
Defined in Generics.Diff.Special.Tree Methods (==) :: CustomTreeDiffError a -> CustomTreeDiffError a -> Bool # (/=) :: CustomTreeDiffError a -> CustomTreeDiffError a -> Bool # | |
Orphan instances
| Diff a => Diff (Tree a) Source # | |
| Diff a => SpecialDiff (Tree a) Source # | Generically-derived instance. |
Associated Types type SpecialDiffError (Tree a) # Methods specialDiff :: Tree a -> Tree a -> Maybe (SpecialDiffError (Tree a)) # renderSpecialDiffError :: SpecialDiffError (Tree a) -> Doc # | |