Safe Haskell | None |
---|
- data Dictionary
- dictionaryType :: Type
- new :: IO Dictionary
- clear :: Dictionary -> IO ()
- contains :: Object key => Dictionary -> key -> IO Bool
- copy :: Dictionary -> IO Dictionary
- getItem :: Object key => Dictionary -> key -> IO (Maybe SomeObject)
- setItem :: (Object key, Object value) => Dictionary -> key -> value -> IO ()
- deleteItem :: Object key => Dictionary -> key -> IO ()
- items :: Dictionary -> IO List
- keys :: Dictionary -> IO List
- values :: Dictionary -> IO List
- size :: Dictionary -> IO Integer
- merge :: Mapping b => Dictionary -> b -> Bool -> IO ()
- update :: Mapping b => Dictionary -> b -> IO ()
- mergeFromSeq2 :: Object seq2 => Dictionary -> seq2 -> Bool -> IO ()
Documentation
clear :: Dictionary -> IO ()Source
Empty an existing dictionary of all key-value pairs.
copy :: Dictionary -> IO DictionarySource
Return a new dictionary that contains the same key-value pairs as the old dictionary.
getItem :: Object key => Dictionary -> key -> IO (Maybe SomeObject)Source
Return the object from a dictionary which has a key key. Return
Nothing
if the key is not present.
setItem :: (Object key, Object value) => Dictionary -> key -> value -> IO ()Source
Inserts value into a dictionary with a key of key. key must be
hashable; if it isn’t, throws TypeError
.
deleteItem :: Object key => Dictionary -> key -> IO ()Source
Remove the entry in a dictionary with key key. key must be hashable;
if it isn’t, throws TypeError
.
items :: Dictionary -> IO ListSource
Return a List
containing all the items in the dictionary, as in
the Python method dict.items()
.
keys :: Dictionary -> IO ListSource
Return a List
containing all the keys in the dictionary, as in
the Python method dict.keys()
.
values :: Dictionary -> IO ListSource
Return a List
containing all the values in the dictionary, as in
the Python method dict.values()
.
size :: Dictionary -> IO IntegerSource
Return the number of items in the dictionary. This is equivalent to
len(d)
.
merge :: Mapping b => Dictionary -> b -> Bool -> IO ()Source
Iterate over mapping object b adding key-value pairs to a dictionary.
b may be a dictionary, or any object supporting keys
and getItem
.
If the third parameter is True
, existing pairs in will be replaced if a
matching key is found in b, otherwise pairs will only be added if there
is not already a matching key.
update :: Mapping b => Dictionary -> b -> IO ()Source
This is the same as (\a b ->
in Haskell, or
merge
a b True)a.update(b)
in Python.
mergeFromSeq2 :: Object seq2 => Dictionary -> seq2 -> Bool -> IO ()Source
Update or merge into a dictionary, from the key-value pairs in seq2.
seq2 must be an iterable object producing iterable objects of length 2,
viewed as key-value pairs. In case of duplicate keys, the last wins if
the third parameter is True
, otherwise the first wins. Equivalent
Python:
def mergeFromSeq2(a, seq2, override): for key, value in seq2: if override or key not in a: a[key] = value