configuration-tools-0.6.0: Tools for specifying and parsing configurations
CopyrightCopyright © 2020 Lars Kuhtz <lakuhtz@gmail.com>
LicenseMIT
MaintainerLars Kuhtz <lakuhtz@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Configuration.Utils.Internal.JsonTools

Description

The difference algorithms uses the following identies on JSON Values:

  • An array equals the same array with all Null entries removed.
  • An object equals the same object with all Null valued properties removed.
Synopsis

Documentation

data Diff a Source #

Represent differences between two values

Constructors

OnlyLeft a 
OnlyRight a 
Conflict a a 
Both a 

Instances

Instances details
Eq a => Eq (Diff a) Source # 
Instance details

Defined in Configuration.Utils.Internal.JsonTools

Methods

(==) :: Diff a -> Diff a -> Bool #

(/=) :: Diff a -> Diff a -> Bool #

Ord a => Ord (Diff a) Source # 
Instance details

Defined in Configuration.Utils.Internal.JsonTools

Methods

compare :: Diff a -> Diff a -> Ordering #

(<) :: Diff a -> Diff a -> Bool #

(<=) :: Diff a -> Diff a -> Bool #

(>) :: Diff a -> Diff a -> Bool #

(>=) :: Diff a -> Diff a -> Bool #

max :: Diff a -> Diff a -> Diff a #

min :: Diff a -> Diff a -> Diff a #

Generic (Diff a) Source # 
Instance details

Defined in Configuration.Utils.Internal.JsonTools

Associated Types

type Rep (Diff a) :: Type -> Type #

Methods

from :: Diff a -> Rep (Diff a) x #

to :: Rep (Diff a) x -> Diff a #

ToJSON a => ToJSON (Diff a) Source # 
Instance details

Defined in Configuration.Utils.Internal.JsonTools

FromJSON a => FromJSON (Diff a) Source # 
Instance details

Defined in Configuration.Utils.Internal.JsonTools

type Rep (Diff a) Source # 
Instance details

Defined in Configuration.Utils.Internal.JsonTools

diff :: Value -> Value -> Value Source #

Merge two JSON values and annotate the result with the differences.

resolve :: (Diff Value -> Value) -> Value -> Value Source #

Resolve differences between two JSON values using the provided conflict resolution function.

Conflict Resoluation Strategies

merge :: Diff Value -> Value Source #

Merge all non-conflicting differences. Leave the conflict annotations in the result.

mergeLeft :: Diff Value -> Value Source #

Merge all differences. Pick the left value in case of a conflict.

mergeRight :: Diff Value -> Value Source #

Merge all differences. Pick the right value in case of a conflict.

resolveLeft :: Diff Value -> Value Source #

Resolve all differences by choosing the left value.

resolveOnlyLeft :: Diff Value -> Value Source #

Keep values that only occure in the left value. Remove all values that occur in the right value or in both.

The result is the left value minus the right value.

resolveRight :: Diff Value -> Value Source #

Resolve all differences by choosing the right value.

resolveOnlyRight :: Diff Value -> Value Source #

Keep values that only occure in the right value. Remove all values that occur in the left value or in both.

The result is the right value minus the left value.