Copyright | (c) 2018-2023 Kowainik |
---|---|
License | MIT |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Stability | Stable |
Portability | Portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
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
class StaticMap t => DynamicMap t where Source #
Modifiable Map.
Since: 0.1.0
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' myHashMap
False
>>>
notMember 'c' myHashMap
True
Since: 0.1.0
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