HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulepatience-0.3Haskell2010

Patience.Map

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

Contents
  1. Types
  2. Diffing
  3. Case analysis on Delta
  4. Construction of special maps from a diff
  5. Mapping
Synopsis
  • Packagepatience-0.3
  • Exports22
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceMap.hs

Types

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

Case analysis on Delta

Construction of special maps from a diff

Mapping

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.