Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
This module exports many functions for querying and modifying LMDB databases using common idioms (albeit in monadic form).
- null :: Database k v -> Transaction mode Bool
- size :: Database k v -> Transaction mode Int
- member :: Serialise k => k -> Database k v -> Transaction mode Bool
- notMember :: Serialise k => k -> Database k v -> Transaction mode Bool
- lookup :: (Serialise k, Serialise v) => k -> Database k v -> Transaction mode (Maybe v)
- findWithDefault :: (Serialise k, Serialise v) => v -> k -> Database k v -> Transaction mode v
- insert :: (Serialise k, Serialise v) => k -> v -> Database k v -> Transaction ReadWrite ()
- insertWith :: (Serialise k, Serialise v) => (v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite ()
- insertWithKey :: (Serialise k, Serialise v) => (k -> v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite ()
- insertLookupWithKey :: (Serialise k, Serialise v) => (k -> v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite (Maybe v)
- delete :: Serialise k => k -> Database k v -> Transaction ReadWrite Bool
- adjust :: (Serialise k, Serialise v) => (v -> v) -> k -> Database k v -> Transaction ReadWrite Bool
- adjustWithKey :: (Serialise k, Serialise v) => (k -> v -> v) -> k -> Database k v -> Transaction ReadWrite Bool
- update :: (Serialise k, Serialise v) => (v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite Bool
- updateWithKey :: (Serialise k, Serialise v) => (k -> v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite Bool
- updateLookupWithKey :: (Serialise k, Serialise v) => (k -> v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite (Maybe v)
- alter :: (Serialise k, Serialise v) => (Maybe v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite ()
- foldr :: Serialise v => (v -> b -> b) -> b -> Database k v -> Transaction mode b
- foldl :: Serialise v => (a -> v -> a) -> a -> Database k v -> Transaction mode a
- foldrWithKey :: (Serialise k, Serialise v) => (k -> v -> b -> b) -> b -> Database k v -> Transaction mode b
- foldlWithKey :: (Serialise k, Serialise v) => (a -> k -> v -> a) -> a -> Database k v -> Transaction mode a
- foldDatabaseWithKey :: (Monoid m, Serialise k, Serialise v) => (k -> v -> m) -> Database k v -> Transaction mode m
- elems :: Serialise v => Database k v -> Transaction mode [v]
- keys :: Serialise k => Database k v -> Transaction mode [k]
- toList :: (Serialise k, Serialise v) => Database k v -> Transaction mode [(k, v)]
Query
member :: Serialise k => k -> Database k v -> Transaction mode Bool Source #
Is the key a member of the database? See also notMember
.
notMember :: Serialise k => k -> Database k v -> Transaction mode Bool Source #
Is the key not a member of the database? See also member
.
findWithDefault :: (Serialise k, Serialise v) => v -> k -> Database k v -> Transaction mode v Source #
The expression (
returns the value at key
findWithDefault
def k db)k
or returns default value def
when the key is not in the database.
Modification
Insertion
insert :: (Serialise k, Serialise v) => k -> v -> Database k v -> Transaction ReadWrite () Source #
Insert a new key and value in the database. If the key is already present
in the database, the associated value is replaced with the supplied
value. insert
is equivalent to
.insertWith
const
insertWith :: (Serialise k, Serialise v) => (v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite () Source #
Insert with a function, combining new value and old value.
will insert the pair insertWith
f key value db(key, value)
into db
if key does
not exist in the database. If the key does exist, the function will insert
the pair (key, f new_value old_value)
.
insertWithKey :: (Serialise k, Serialise v) => (k -> v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite () Source #
Insert with a function, combining key, new value and old
value.
will insert the pair insertWithKey
f key value db(key, value)
into db
if key does not exist in the database. If the key does exist, the
function will insert the pair (key, f key new_value old_value)
. Note that
the key passed to f
is the same key passed to insertWithKey
.
insertLookupWithKey :: (Serialise k, Serialise v) => (k -> v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite (Maybe v) Source #
Combines insert operation with old value retrieval. The monadic action
(
returns the same value as insertLookupWithKey
f k x db)(
but has the same effect as lookup
k
db)(
.insertWithKey
f k x db)
Delete/Update
adjust :: (Serialise k, Serialise v) => (v -> v) -> k -> Database k v -> Transaction ReadWrite Bool Source #
adjustWithKey :: (Serialise k, Serialise v) => (k -> v -> v) -> k -> Database k v -> Transaction ReadWrite Bool Source #
update :: (Serialise k, Serialise v) => (v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite Bool Source #
updateWithKey :: (Serialise k, Serialise v) => (k -> v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite Bool Source #
The monadic action (
updates the value updateWithKey
f k db)x
at
k
(if it is in the database). If (f k x)
is Nothing
, the element is
deleted. If it is (
, the key Just
y)k
is bound to the new value y
.
updateLookupWithKey :: (Serialise k, Serialise v) => (k -> v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite (Maybe v) Source #
Lookup and update. See also updateWithKey
. The function returns changed
value, if it is updated. Returns the original key value if the database
entry is deleted.
alter :: (Serialise k, Serialise v) => (Maybe v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite () Source #
Folds
foldr :: Serialise v => (v -> b -> b) -> b -> Database k v -> Transaction mode b Source #
Fold the values in the database using the given right-associative binary operator.
foldl :: Serialise v => (a -> v -> a) -> a -> Database k v -> Transaction mode a Source #
Fold the values in the database using the given left-associative binary operator.
foldrWithKey :: (Serialise k, Serialise v) => (k -> v -> b -> b) -> b -> Database k v -> Transaction mode b Source #
Fold the keys and values in the database using the given right-associative binary operator.
foldlWithKey :: (Serialise k, Serialise v) => (a -> k -> v -> a) -> a -> Database k v -> Transaction mode a Source #
Fold the keys and values in the database using the given left-associative binary operator.
foldDatabaseWithKey :: (Monoid m, Serialise k, Serialise v) => (k -> v -> m) -> Database k v -> Transaction mode m Source #
Fold the keys and values in the database using the given monoid.
Conversion
elems :: Serialise v => Database k v -> Transaction mode [v] Source #
Return all elements of the database in the order of their keys.