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

Modulerelude-1.2.0.0Haskell2010

Relude.Extra.Map

SPDX-License-Identifier : MIT Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable

Contains implementation of polymorphic type classes for data types Set and Map.

  • 2 classes
  • 6 values
  • Packagerelude-1.2.0.0
  • Exports8
  • LanguageHaskell2010
  • LicenceMIT
  • SourceMap.hs
classclass StaticMap t where
#

Read-only map or set. Contains polymorphic functions which work for both sets and maps.

Associated types

  • type family Key t
  • type family Val t

Methods

Instances6StaticMap
classclass StaticMap t => DynamicMap t where
#

Modifiable Map.

Methods

Instances3DynamicMap
value(!?) :: StaticMap t => t -> Key t -> Maybe (Val t)
#

Operator version of lookup function.

Example2 expressions
let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]myHashMap !? 'b'Just "yyy"
Example1 expression
myHashMap !? 'd'Nothing
valuenotMember :: StaticMap t => Key t -> t -> Bool
#

Inverse of member function.

Example2 expressions
let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]notMember 'b' myHashMapFalse
Example1 expression
notMember 'c' myHashMapTrue
valuelookupDefault
  1. :: StaticMap t
  2. => Val t

    Default value to return.

  3. -> Key t

    Key to search

  4. -> t

    Container to search

  5. -> Val t
#

Return the value to which the specified key is mapped, or the default value if this map contains no mapping for the key.

Example2 expressions
let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]lookupDefault "zzz" 'b' myHashMap"yyy"
Example1 expression
lookupDefault "zzz" 'c' myHashMap"zzz"

To pairs

3 declarations
valuetoPairs :: (IsList t, Item t ~ (a, b)) => t -> [(a, b)]
#

Converts the structure to the list of the key-value pairs.

Example1 expression
toPairs (HashMap.fromList [('a', "xxx"), ('b', "yyy")])[('a',"xxx"),('b',"yyy")]
valuekeys :: (IsList t, Item t ~ (a, b)) => t -> [a]
#

Converts the structure to the list of the keys.

Example1 expression
keys (HashMap.fromList [('a', "xxx"), ('b', "yyy")])"ab"
valueelems :: (IsList t, Item t ~ (a, b)) => t -> [b]
#

Converts the structure to the list of the values.

Example1 expression
elems (HashMap.fromList [('a', "xxx"), ('b', "yyy")])["xxx","yyy"]