HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulepatience-0.3Haskell2010

Patience.Map

This module provides a lossless way to do diffing between two Maps, and ways to manipulate the diffs.

  • 1 type
  • 21 values
  • Packagepatience-0.3
  • Exports22
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceMap.hs

Types

1 declaration
datadata Delta a
#

The result of a diff of an entry within two Maps.

In two Maps m1 and m2, when performing a diff, this type encodes the following situations:

Same key, different values: Stores the two values in the Delta constructor.

Same key, same values: Stores the value in the Same constructor.

Key exists in m1 but not m2: Stores the value in the Old constructor.

Key exists in m2 but not m1: Stores the value in the New constructor.

This behaviour ensures that we don't lose any information, meaning we can reconstruct either of the original Map k a from a Map k (Delta a). (Note that this slightly differs from diff, which does not care about the possibility of reconstruction).

Constructors

Instances10Functor, Foldable, Traversable, Generic1, Eq, Ord, …

Diffing

1 declaration

Case analysis on Delta

9 declarations

Construction of special maps from a diff

5 declarations
valuetoDelta :: Map k (Delta a) -> Map k (a, a)
#

Retrieve only the DeltaUnit values out of the diff map.

Mapping

6 declarations
valuemapSame :: Eq a => (a -> b) -> Map k (Delta a) -> Map k b
#

Map over all Same values, returning a map of just the transformed values. This can be more efficient than calling toSame and then Data.Map's map.

valuemapOld :: (a -> b) -> Map k (Delta a) -> Map k b
#

Map over all Old values, returning a map of just the transformed values. This can be more efficient than calling toOld and then Data.Map's map.

valuemapNew :: (a -> b) -> Map k (Delta a) -> Map k b
#

Map over all New values, returning a map of just the transformed values. This can be more efficient than calling toNew and then Data.Map's map.

valuemapOld' :: (a -> a) -> Map k (Delta a) -> Map k (Delta a)
#

Map over all the Old values, preserving the remaining values in the map.

valuemapNew' :: (a -> a) -> Map k (Delta a) -> Map k (Delta a)
#

Map over all the New values, preserving the remaining values in the map.