Copyright | (c) 2018-2019 Kowainik |
---|---|
License | MIT |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Safe Haskell | None |
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.
class StaticMap t => DynamicMap t where Source #
Modifiable Map.
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
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
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"
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")]