| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.RadixTree
- data RadixTree
- data RadixNode = RadixNode !Text !RadixTree
- data CompressedRadixTree
- fromFoldable :: Foldable f => f Text -> RadixTree
- compressBy :: Text -> RadixTree -> Maybe CompressedRadixTree
- class RadixParsing radixtree where
- search :: (Monad m, CharParsing m, RadixParsing radixtree) => radixtree -> m [Text]
Documentation
A radixtree. Construct with fromFoldable, and use with parse.
A node in a radixtree. To advance from here a parser must parse the Text
(i.e., the prefix) value at this node.
data CompressedRadixTree Source #
A normal RadixTree stores a new Text at every node. In contrast, a
CompressedRadixTree takes a single corpus Text which is indexed into by
nodes. This can save a lot of memory (e.g., using the radix trees from the
parsing benchmarks in this package, the CompressedRadixTree version is
254032 bytes, whereas the ordinary RadixTree is a rotund 709904 bytes) at
no runtime cost.
Construction
compressBy :: Text -> RadixTree -> Maybe CompressedRadixTree Source #
Compress a RadixTree given a corpus. All values in the tree be findable
within the corpus, though the corpus does not have to necessarily be the
direct source of the tree
Parsing with radix trees
class RadixParsing radixtree where Source #
Minimal complete definition
Methods
parse :: CharParsing m => radixtree -> m Text Source #
Instances
search :: (Monad m, CharParsing m, RadixParsing radixtree) => radixtree -> m [Text] Source #
Find all occurences of the terms in a RadixTree from this point on. This
will consume the entire remaining input. Can lazily produce results (but this
depends on your parser).