HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduledependent-map-0.4.0.0Haskell98

Data.Dependent.Map.Internal

  • 3 types
  • 31 values
datadata DMap (k1 :: k -> Type) (f :: k -> Type) where
#

Dependent maps: k is a GADT-like thing with a facility for rediscovering its type parameter, elements of which function as identifiers tagged with the type of the thing they identify. Real GADTs are one useful instantiation of k, as are Tags from Data.Unique.Tag in the 'prim-uniq' package.

Semantically, DMap k f is equivalent to a set of DSum k f where no two elements have the same tag.

More informally, DMap is to dependent products as M.Map is to (->). Thus it could also be thought of as a partial (in the sense of "partial function") dependent product.

Constructors

Instances6Eq, Ord, Read, Show, Semigroup, Monoid
valueempty :: DMap k2 f
#

O(1). The empty map.

empty      == fromList []
size empty == 0
valuesingleton :: k2 v -> f v -> DMap k2 f
#

O(1). A map with a single element.

singleton 1 'a'        == fromList [(1, 'a')]
size (singleton 1 'a') == 1
valuesize :: DMap k2 f -> Int
#

O(1). The number of elements in the map.

valuelookup :: GCompare k2 => k2 v -> DMap k2 f -> Maybe (f v)
#

O(log n). Lookup the value at a key in the map.

The function will return the corresponding value as (Just value), or Nothing if the key isn't in the map.

valuedeleteFindMin :: DMap k2 f -> (DSum k2 f, DMap k2 f)
#

O(log n). Delete and find the minimal element.

deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")])
deleteFindMin                                            Error: can not return the minimal element of an empty map
datadata (:*:) a b
#

A strict pair.

Constructors

  • a :*: binfixr 1
valuetoPair :: a :*: b -> (a, b)
#

Convert a strict pair to a pair.

valuetoTriple :: Triple' a b c -> (a, b, c)
#

Convert a strict triple to a triple.

valueminViewWithKey :: DMap k2 f -> Maybe (DSum k2 f, DMap k2 f)
#

O(log n). Retrieves the minimal (key :=> value) entry of the map, and the map stripped of that element, or Nothing if passed an empty map.

valuemaxViewWithKey :: DMap k2 f -> Maybe (DSum k2 f, DMap k2 f)
#

O(log n). Retrieves the maximal (key :=> value) entry of the map, and the map stripped of that element, or Nothing if passed an empty map.

valuedeleteFindMax :: DMap k2 f -> (DSum k2 f, DMap k2 f)
#

O(log n). Delete and find the maximal element.

deleteFindMax (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((10,"c"), fromList [(3,"b"), (5,"a")])
deleteFindMax empty                                      Error: can not return the maximal element of an empty map