HORIZON HASKELLDocslts/ghc-9.14.x6d5fdfd2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 6d5fdfd · 2026-10-12

Moduledependent-map-0.4.0.1Haskell2010

Data.Dependent.Map.Internal

Synopsis
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
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
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