Safe Haskell | None |
---|---|

Language | Haskell98 |

The document table interface.

- class DocumentWrapper (DValue i) => DocTable i where
- type DValue i :: *
- null :: Monad m => i -> m Bool
- size :: Monad m => i -> m Int
- lookup :: Monad m => DocId -> i -> m (Maybe (DValue i))
- lookupByURI :: Monad m => URI -> i -> m (Maybe DocId)
- union :: Monad m => i -> i -> m i
- disjoint :: Monad m => i -> i -> m Bool
- insert :: Monad m => DValue i -> i -> m (DocId, i)
- update :: Monad m => DocId -> DValue i -> i -> m i
- adjust :: Monad m => (DValue i -> m (DValue i)) -> DocId -> i -> m i
- adjustByURI :: Monad m => (DValue i -> m (DValue i)) -> URI -> i -> m i
- delete :: Monad m => DocId -> i -> m i
- deleteByURI :: Monad m => URI -> i -> m i
- difference :: Monad m => DocIdSet -> i -> m i
- differenceByURI :: Monad m => Set URI -> i -> m i
- map :: Monad m => (DValue i -> DValue i) -> i -> m i
- filter :: Monad m => (DValue i -> Bool) -> i -> m i
- toMap :: Monad m => i -> m (DocIdMap (DValue i))
- empty :: i

- restrict :: (Functor m, Monad m, Applicative m, DocTable i) => DocIdSet -> i -> m i
- toJSON'DocTable :: (Functor m, Monad m, Applicative m, DocTable i) => i -> m Value
- fromJSON'DocTable :: (Functor m, Monad m, Applicative m, DocTable i) => Value -> m i

# Documentation

class DocumentWrapper (DValue i) => DocTable i where Source

The document table type class which needs to be implemented to be used by the `Interpreter`

.
The type parameter `i`

is the implementation.
The implementation must have a value type parameter.

null, size, lookup, lookupByURI, union, disjoint, insert, update, delete, difference, map, filter, toMap, empty

null :: Monad m => i -> m Bool Source

Test whether the document table is empty.

size :: Monad m => i -> m Int Source

Returns the number of unique documents in the table.

lookup :: Monad m => DocId -> i -> m (Maybe (DValue i)) Source

Lookup a document by its ID.

lookupByURI :: Monad m => URI -> i -> m (Maybe DocId) Source

union :: Monad m => i -> i -> m i Source

Union of two disjoint document tables. It is assumed, that the
DocIds and the document `URI`

s of both indexes are disjoint.

disjoint :: Monad m => i -> i -> m Bool Source

Test whether the `DocId`

s of both tables are disjoint.

insert :: Monad m => DValue i -> i -> m (DocId, i) Source

Insert a document into the table. Returns a tuple of the `DocId`

for that document and the
new table. If a document with the same `URI`

is already present, its id will be returned
and the table is returned unchanged.

update :: Monad m => DocId -> DValue i -> i -> m i Source

Update a document with a certain `DocId`

.

adjust :: Monad m => (DValue i -> m (DValue i)) -> DocId -> i -> m i Source

Update a document by `DocId`

with the result of the provided function.

adjustByURI :: Monad m => (DValue i -> m (DValue i)) -> URI -> i -> m i Source

Update a document by `URI`

with the result of the provided function.

delete :: Monad m => DocId -> i -> m i Source

Removes the document with the specified `DocId`

from the table.

deleteByURI :: Monad m => URI -> i -> m i Source

Removes the document with the specified `URI`

from the table.

difference :: Monad m => DocIdSet -> i -> m i Source

Deletes a set of documents by `DocId`

from the table.

differenceByURI :: Monad m => Set URI -> i -> m i Source

Deletes a set of documents by `URI`

from the table.

map :: Monad m => (DValue i -> DValue i) -> i -> m i Source

Map a function over all values of the document table.

filter :: Monad m => (DValue i -> Bool) -> i -> m i Source

Filters all documents that satisfy the predicate.

toMap :: Monad m => i -> m (DocIdMap (DValue i)) Source

Convert document table to a `DocIdMap`

.

Empty `DocTable`

.

DocumentWrapper e => DocTable (Documents e) |

toJSON'DocTable :: (Functor m, Monad m, Applicative m, DocTable i) => i -> m Value Source

JSON dump of the document table.

fromJSON'DocTable :: (Functor m, Monad m, Applicative m, DocTable i) => Value -> m i Source

JSON import of the document table.