generic-diff-instances
Safe HaskellSafe-Inferred
LanguageHaskell2010

Generics.Diff.Special.Map

Description

A worked example of implementing SpecialDiff (and thereby Diff) for Maps.

We make the choice to prioritise speed over exhaustiveness: in other words we stop when we find one difference between the two input maps. Alternatively, we could have gone the other way and enumerated all the difference between the inputs, using some kind of intersection test. This is left as an exercise for the reader.

Synopsis

Documentation

data MapDiffError k v Source #

For Maps, we only pick out (maximum) one difference between the two inputs. There are three possibilities:

Constructors

DiffAtKey k (DiffError v)

A key is found in both maps, but they have different values.

LeftMissingKey k

The right set contains an element that isn't found in the left set

RightMissingKey k

The left set contains an element that isn't found in the right set

Instances

Instances details
Show k => Show (MapDiffError k v) Source # 
Instance details

Defined in Generics.Diff.Special.Map

Eq k => Eq (MapDiffError k v) Source # 
Instance details

Defined in Generics.Diff.Special.Map

Methods

(==) :: MapDiffError k v -> MapDiffError k v -> Bool #

(/=) :: MapDiffError k v -> MapDiffError k v -> Bool #

Orphan instances

(Show k, Ord k, Diff v) => Diff (Map k v) Source # 
Instance details

Methods

diff :: Map k v -> Map k v -> DiffResult (Map k v) #

diffList :: [Map k v] -> [Map k v] -> DiffResult [Map k v] #

(Show k, Ord k, Diff v) => SpecialDiff (Map k v) Source # 
Instance details

Associated Types

type SpecialDiffError (Map k v) #