generic-diff-instances
Safe HaskellSafe-Inferred
LanguageHaskell2010

Generics.Diff.Special.Set

Description

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

We make the choice to prioritise speed over exhaustiveness: in other words we stop when we find one difference between the two input sets. 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.

Note that the implementation for maps in Generics.Diff.Special.Map is very similar; this is since a Set k can be seen as equivalent to Map k ().

Synopsis

Documentation

data SetDiffError k Source #

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

Constructors

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 (SetDiffError k) Source # 
Instance details

Defined in Generics.Diff.Special.Set

Eq k => Eq (SetDiffError k) Source # 
Instance details

Defined in Generics.Diff.Special.Set

Orphan instances

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

Methods

diff :: Set k -> Set k -> DiffResult (Set k) #

diffList :: [Set k] -> [Set k] -> DiffResult [Set k] #

(Show k, Eq k, Ord k) => SpecialDiff (Set k) Source # 
Instance details

Associated Types

type SpecialDiffError (Set k) #