| Copyright | Guillaume Sabbagh 2022 |
|---|---|
| License | LGPL-3.0-or-later |
| Maintainer | guillaumesabbagh@protonmail.com |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.WeakMap.Safe
Description
Non-clashing functions for Maps.
Synopsis
- weakMap :: AssociationList k v -> Map k v
- weakMapFromSet :: Set (k, v) -> Map k v
- (|?|) :: Eq k => Map k v -> k -> Maybe v
- (|!|) :: Eq k => Map k v -> k -> v
- (|.|) :: Eq b => Map b c -> Map a b -> Map a c
- idFromSet :: Set a -> Map a a
- memorizeFunction :: (k -> v) -> Set k -> Map k v
- elems' :: Eq k => Map k a -> Set a
- keys' :: Map k v -> Set k
- domain :: Map k a -> Set k
- image :: Eq k => Map k a -> Set a
- inverse :: (Eq k, Eq v) => Map k v -> Maybe (Map v k)
- pseudoInverse :: Map k v -> Map v k
- enumerateMaps :: (Eq a, Eq b) => Set a -> Set b -> Set (Map a b)
- mapKeysAndValues :: ((k1, v1) -> (k2, v2)) -> Map k1 v1 -> Map k2 v2
- (<|$|>) :: ((k1, v1) -> (k2, v2)) -> Map k1 v1 -> Map k2 v2
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 #
(|?|) :: 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 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.
memorizeFunction :: (k -> v) -> Set k -> Map k v Source #
O(n). Memorize a Haskell function on a given finite domain. Alias of fromSet.
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.
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.
mapKeysAndValues :: ((k1, v1) -> (k2, v2)) -> Map k1 v1 -> Map k2 v2 Source #
Map a function to the couples (key,value).