| Copyright | (c) 2018-2020 Kowainik |
|---|---|
| License | MIT |
| Maintainer | Kowainik <xrom.xkov@gmail.com> |
| Stability | Experimental |
| Portability | Portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Relude.Extra.Map
Contents
Synopsis
- class StaticMap t where
- class StaticMap t => DynamicMap t where
- (!?) :: StaticMap t => t -> Key t -> Maybe (Val t)
- notMember :: StaticMap t => Key t -> t -> Bool
- lookupDefault :: StaticMap t => Val t -> Key t -> t -> Val t
- toPairs :: (IsList t, Item t ~ (a, b)) => t -> [(a, b)]
- keys :: (IsList t, Item t ~ (a, b)) => t -> [a]
- elems :: (IsList t, Item t ~ (a, b)) => t -> [b]
Documentation
class StaticMap t where Source #
Read-only map or set. Contains polymorphic functions which work for both sets and maps.
Since: 0.1.0
Instances
| StaticMap IntSet Source # | Since: 0.1.0 |
| StaticMap (IntMap v) Source # | Since: 0.1.0 |
| Ord a => StaticMap (Set a) Source # | Since: 0.1.0 |
| (Eq a, Hashable a) => StaticMap (HashSet a) Source # | Since: 0.1.0 |
| Ord k => StaticMap (Map k v) Source # | Since: 0.1.0 |
| (Eq k, Hashable k) => StaticMap (HashMap k v) Source # | Since: 0.1.0 |
class StaticMap t => DynamicMap t where Source #
Modifiable Map.
Since: 0.1.0
Methods
insert :: Key t -> Val t -> t -> t Source #
insertWith :: (Val t -> Val t -> Val t) -> Key t -> Val t -> t -> t Source #
delete :: Key t -> t -> t Source #
alter :: (Maybe (Val t) -> Maybe (Val t)) -> Key t -> t -> t Source #
Instances
(!?) :: StaticMap t => t -> Key t -> Maybe (Val t) infixl 9 Source #
Operator version of lookup function.
>>>let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]>>>myHashMap !? 'b'Just "yyy"
>>>myHashMap !? 'd'Nothing
Since: 0.1.0
notMember :: StaticMap t => Key t -> t -> Bool Source #
Inverse of member function.
>>>let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]>>>notMember 'b' myHashMapFalse
>>>notMember 'c' myHashMapTrue
Since: 0.1.0
Arguments
| :: StaticMap t | |
| => Val t | Default value to return. |
| -> Key t | Key to search |
| -> t | Container to search |
| -> 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.
>>>let myHashMap = HashMap.fromList [('a', "xxx"), ('b', "yyy")]>>>lookupDefault "zzz" 'b' myHashMap"yyy"
>>>lookupDefault "zzz" 'c' myHashMap"zzz"
Since: 0.1.0
To pairs
toPairs :: (IsList t, Item t ~ (a, b)) => t -> [(a, b)] Source #
Converts the structure to the list of the key-value pairs.
>>>toPairs (HashMap.fromList [('a', "xxx"), ('b', "yyy")])[('a',"xxx"),('b',"yyy")]
Since: 0.1.0