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 :: Binary k => k -> Database k v -> Transaction mode Bool
- notMember :: Binary k => k -> Database k v -> Transaction mode Bool
- lookup :: (Binary k, Binary v) => k -> Database k v -> Transaction mode (Maybe v)
- findWithDefault :: (Binary k, Binary v) => v -> k -> Database k v -> Transaction mode v
- insert :: (Binary k, Binary v) => k -> v -> Database k v -> Transaction ReadWrite ()
- insertWith :: (Binary k, Binary v) => (v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite ()
- insertWithKey :: (Binary k, Binary v) => (k -> v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite ()
- insertLookupWithKey :: (Binary k, Binary v) => (k -> v -> v -> v) -> k -> v -> Database k v -> Transaction ReadWrite (Maybe v)
- delete :: Binary k => k -> Database k v -> Transaction ReadWrite Bool
- adjust :: (Binary k, Binary v) => (v -> v) -> k -> Database k v -> Transaction ReadWrite Bool
- adjustWithKey :: (Binary k, Binary v) => (k -> v -> v) -> k -> Database k v -> Transaction ReadWrite Bool
- update :: (Binary k, Binary v) => (v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite Bool
- updateWithKey :: (Binary k, Binary v) => (k -> v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite Bool
- updateLookupWithKey :: (Binary k, Binary v) => (k -> v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite (Maybe v)
- alter :: (Binary k, Binary v) => (Maybe v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite ()
- foldr :: Binary v => (v -> b -> b) -> b -> Database k v -> Transaction mode b
- foldl :: Binary v => (a -> v -> a) -> a -> Database k v -> Transaction mode a
- foldrWithKey :: (Binary k, Binary v) => (k -> v -> b -> b) -> b -> Database k v -> Transaction mode b
- foldlWithKey :: (Binary k, Binary v) => (a -> k -> v -> a) -> a -> Database k v -> Transaction mode a
- foldDatabaseWithKey :: (Monoid m, Binary k, Binary v) => (k -> v -> m) -> Database k v -> Transaction mode m
- elems :: Binary v => Database k v -> Transaction mode [v]
- keys :: Binary k => Database k v -> Transaction mode [k]
- toList :: (Binary k, Binary v) => Database k v -> Transaction mode [(k, v)]
Query
member :: Binary k => k -> Database k v -> Transaction mode Bool Source #
Is the key a member of the database? See also notMember
.
notMember :: Binary k => k -> Database k v -> Transaction mode Bool Source #
Is the key not a member of the database? See also member
.
findWithDefault :: (Binary k, Binary 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 :: (Binary k, Binary 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 :: (Binary k, Binary 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 :: (Binary k, Binary 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 :: (Binary k, Binary 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 :: (Binary k, Binary v) => (v -> v) -> k -> Database k v -> Transaction ReadWrite Bool Source #
adjustWithKey :: (Binary k, Binary v) => (k -> v -> v) -> k -> Database k v -> Transaction ReadWrite Bool Source #
update :: (Binary k, Binary v) => (v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite Bool Source #
updateWithKey :: (Binary k, Binary 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 :: (Binary k, Binary 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 :: (Binary k, Binary v) => (Maybe v -> Maybe v) -> k -> Database k v -> Transaction ReadWrite () Source #
Folds
foldr :: Binary 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 :: Binary 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 :: (Binary k, Binary 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 :: (Binary k, Binary 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, Binary k, Binary 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 :: Binary v => Database k v -> Transaction mode [v] Source #
Return all elements of the database in the order of their keys.