Copyright | Guillaume Sabbagh 2021 |
---|---|
License | GPL-3 |
Maintainer | guillaumesabbagh@protonmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
The type for association lists.
It is used when the Ord
constraint of Map
is too restrictive.
Synopsis
- type AssociationList a b = [(a, b)]
- keys :: AssociationList a b -> [a]
- values :: AssociationList a b -> [b]
- (!-) :: Eq a => a -> AssociationList a b -> Maybe b
- (!-!) :: Eq a => AssociationList a b -> a -> b
- (!-?) :: Eq a => b -> a -> AssociationList a b -> b
- (!-.) :: (Eq a, Eq b) => AssociationList b c -> AssociationList a b -> AssociationList a c
- mkAssocListIdentity :: [a] -> AssociationList a a
- enumAssocLists :: [a] -> [b] -> [AssociationList a b]
- functToAssocList :: (a -> b) -> [a] -> AssociationList a b
- assocListToFunct :: Eq a => AssociationList a b -> a -> b
- inverse :: AssociationList a b -> AssociationList b a
- removeKey :: Eq a => AssociationList a b -> a -> AssociationList a b
- removeValue :: Eq b => AssociationList a b -> b -> AssociationList a b
Documentation
type AssociationList a b = [(a, b)] Source #
The type of association lists (a list of couples).
keys :: AssociationList a b -> [a] Source #
Returns the keys of the association list.
values :: AssociationList a b -> [b] Source #
Returns the values of the association list.
(!-) :: Eq a => a -> AssociationList a b -> Maybe b Source #
If the key is in the association list, returns Just the value associated, otherwise Nothing.
Same as lookup in Map
.
(!-!) :: Eq a => AssociationList a b -> a -> b Source #
If the key is in the association list, returns the value associated, otherwise throws an error.
Same as (!) in Map
.
(!-?) :: Eq a => b -> a -> AssociationList a b -> b Source #
If the key is in the association list, returns the value associated, otherwise returns a default value.
Same as findWithDefault in Map
.
(!-.) :: (Eq a, Eq b) => AssociationList b c -> AssociationList a b -> AssociationList a c Source #
Composition of association lists.
mkAssocListIdentity :: [a] -> AssociationList a a Source #
Constructs the identity association list of a list of values.
For example, mkAssocListIdentity [1,2,3] = [(1,1),(2,2),(3,3)]
enumAssocLists :: [a] -> [b] -> [AssociationList a b] Source #
Enumerates all association lists possible between a domain and a codomain.
functToAssocList :: (a -> b) -> [a] -> AssociationList a b Source #
Transforms a function and a domain into an association list.
assocListToFunct :: Eq a => AssociationList a b -> a -> b Source #
Transforms an association list to a function.
inverse :: AssociationList a b -> AssociationList b a Source #
Inverse of an association list
removeKey :: Eq a => AssociationList a b -> a -> AssociationList a b Source #
Remove all couples with a certain key
removeValue :: Eq b => AssociationList a b -> b -> AssociationList a b Source #
Remove all couples with a certain value