WeakSets-1.2.4.0: Simple set types. Useful to create sets of arbitrary types and nested sets.
CopyrightGuillaume Sabbagh 2022
LicenseLGPL-3.0-or-later
Maintainerguillaumesabbagh@protonmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.WeakMap.Safe

Description

Non-clashing functions for Maps.

Synopsis

Documentation

weakMap :: AssociationList k v -> Map k v Source #

O(1). The smart constructor of weak maps. This is the only way of instantiating a Map.

Takes an association list and returns a function which maps to each key the value associated.

If several pairs have the same keys, they are kept until the user wants an association list back.

weakMapFromSet :: Set (k, v) -> Map k v Source #

O(1). Construct a Map from a Set of pairs (key,value).

(|?|) :: Eq k => Map k v -> k -> Maybe v Source #

O(n). Lookup the value at a key in the map. If the map is not defined on the given value returns Nothing, otherwise returns Just the image.

This function is like lookup in Data.Map for function (beware: the order of the argument are reversed).

(|!|) :: Eq k => Map k v -> k -> v Source #

O(n). Unsafe version of (|?|).

This function is like (!) in Data.Map, it is renamed to avoid name collisions.

(|.|) :: Eq b => Map b c -> Map a b -> Map a c Source #

Compose two functions. If the two functions are not composable, strips the functions until they can compose.

idFromSet :: Set a -> Map a a Source #

O(n). Return the identity function associated to a Set.

memorizeFunction :: (k -> v) -> Set k -> Map k v Source #

O(n). Memorize a Haskell function on a given finite domain. Alias of fromSet.

elems' :: Eq k => Map k a -> Set a Source #

O(n^2). Same as elems but returns a Set. Beware that an Eq typeclass must be added.

keys' :: Map k v -> Set k Source #

O(n). Same as keys but returns a Set. No Eq typeclass required.

domain :: Map k a -> Set k Source #

O(n^2). Alias of keys`.

image :: Eq k => Map k a -> Set a Source #

O(n^2). Alias of elems`.

inverse :: (Eq k, Eq v) => Map k v -> Maybe (Map v k) Source #

O(n^2). Try to construct an inverse map.

pseudoInverse :: Map k v -> Map v k Source #

O(n). Return a pseudo inverse g of a Map f such that f |.| g |.| f == f.

enumerateMaps Source #

Arguments

:: (Eq a, Eq b) 
=> Set a

Domain.

-> Set b

Codomain.

-> Set (Map a b)

All maps from domain to codomain.

Return all Functions from a domain to a codomain.