HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduletree-diff-0.4.1Haskell2010

Data.TreeDiff.OMap

Map which remembers the fromList order. This module is minimal on purpose.

  • 1 type
  • 5 values
  • Packagetree-diff-0.4.1
  • Exports6
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later
  • SourceOMap.hs

Ordered map

1 declaration
newtypenewtype OMap k v
#
Instances10Functor, Arbitrary1, Semialign, Unzip, Zip, Eq, …
  • Functor (OMap k)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
  • (Ord k, Arbitrary k) => Arbitrary1 (OMap k)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
  • Ord k => Semialign (OMap k)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
    Example3 expressions
    let xs = fromList [('a', "alpha"), ('b', "beta")]let ys = fromList [('c', 3 :: Int), ('b', 2)]alignWith id xs ysfromList [('a',This "alpha"),('c',That 3),('b',These "beta" 2)]
  • Ord k => Unzip (OMap k)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
  • Ord k => Zip (OMap k)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
  • (Eq k, Eq v) => Eq (OMap k v)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
    Example3 expressions
    xs = toAscList $ fromList [('a', "alpha"), ('b', "beta"), ('g', "gamma")]ys = toAscList $ fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")]xs == ysTrue
    Example2 expressions
    zs = toAscList $ fromList [('d', "delta"), ('b', "beta"), ('a', "alpha")]xs == zsFalse
  • (Ord k, Ord v) => Ord (OMap k v)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
  • (Show k, Show v) => Show (OMap k v)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap

    Note: The instance uses toList, so Equal OMaps can be shown differently.

  • (NFData k, NFData v) => NFData (OMap k v)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap
  • (Ord k, Arbitrary k, Arbitrary v) => Arbitrary (OMap k v)Defined in tree-diff-0.4.1 · Data.TreeDiff.OMap

Conversions

3 declarations
valuetoAscList :: OMap k v -> [(k, v)]
#
Example1 expression
toAscList $ fromList [('a', "alpha"), ('b', "beta"), ('g', "gamma")][('a',"alpha"),('b',"beta"),('g',"gamma")]
Example1 expression
toAscList $ fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")][('a',"alpha"),('b',"beta"),('g',"gamma")]
valuetoList :: OMap k v -> [(k, v)]
#

O(n log n). List in creation order. Doesn't respect Eq instance.

Example1 expression
toList $ fromList [('a', "alpha"), ('b', "beta"), ('g', "gamma")][('a',"alpha"),('b',"beta"),('g',"gamma")]
Example1 expression
toList $ fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")][('g',"gamma"),('b',"beta"),('a',"alpha")]
valuefromList :: Ord k => [(k, v)] -> OMap k v
#
Example1 expression
fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")]fromList [('g',"gamma"),('b',"beta"),('a',"alpha")]

Construction

1 declaration
valueempty :: OMap k v
#
Example1 expression
empty :: OMap String IntegerfromList []

Query

1 declaration
valueelems :: OMap k v -> [v]
#

Elements in key ascending order.