Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

A term index to accelerate matching. An index is a multimap from terms to arbitrary values.

The type of query supported is: given a search term, find all keys such that the search term is an instance of the key, and return the corresponding values.

## Synopsis

- data Index f a
- empty :: Index f a
- null :: Index f a -> Bool
- singleton :: Term f -> a -> Index f a
- insert :: (Symbolic a, ConstantOf a ~ f) => Term f -> a -> Index f a -> Index f a
- delete :: (Eq a, Symbolic a, ConstantOf a ~ f) => Term f -> a -> Index f a -> Index f a
- lookup :: (Has a b, Symbolic b, Has b (TermOf b)) => TermOf b -> Index (ConstantOf b) a -> [b]
- matches :: Term f -> Index f a -> [(Subst f, a)]
- elems :: Index f a -> [a]
- fromList :: (Symbolic a, ConstantOf a ~ f) => [(Term f, a)] -> Index f a
- fromListWith :: (Symbolic a, ConstantOf a ~ f) => (a -> Term f) -> [a] -> Index f a
- invariant :: Index f a -> Bool

# Documentation

A term index: a multimap from

to `Term`

f`a`

.

insert :: (Symbolic a, ConstantOf a ~ f) => Term f -> a -> Index f a -> Index f a Source #

Insert an entry into the index.

delete :: (Eq a, Symbolic a, ConstantOf a ~ f) => Term f -> a -> Index f a -> Index f a Source #

Delete an entry from the index.

lookup :: (Has a b, Symbolic b, Has b (TermOf b)) => TermOf b -> Index (ConstantOf b) a -> [b] Source #

Look up a term in the index. Finds all key-value such that the search term is an instance of the key, and returns an instance of the the value which makes the search term exactly equal to the key.

matches :: Term f -> Index f a -> [(Subst f, a)] Source #

Look up a term in the index. Like `lookup`

, but returns the exact value
that was inserted into the index, not an instance. Also returns a substitution
which when applied to the value gives you the matching instance.

fromList :: (Symbolic a, ConstantOf a ~ f) => [(Term f, a)] -> Index f a Source #

Create an index from a list of items

fromListWith :: (Symbolic a, ConstantOf a ~ f) => (a -> Term f) -> [a] -> Index f a Source #

Create an index from a list of items