Commit 77084ad6 authored by Mike Ledger's avatar Mike Ledger

make more fit for consumption

parent b64ec8eb
# A radix (prefix?) tree parsing library
Takes any old `Foldable` of `Text` values, and provides a parser for any parsers
that have a `CharParsing` instance (from
the [parsers](https://hackage.haskell.org/package/parsers) package, i.e., at
least trifecta, parsec, and attoparsec).
Why this is better than `choice . map text` is speed. That approach becomes
prohibitively slow for "large" corpuses; e.g., for parsing some `Text` from 881
alternatives, the difference is an order of magnitude:
```
Benchmark radixtree-parsing: RUNNING...
benchmarking attoparsec/radix
time 5.082 μs (5.070 μs .. 5.096 μs)
1.000 R² (1.000 R² .. 1.000 R²)
mean 5.095 μs (5.080 μs .. 5.110 μs)
std dev 49.09 ns (39.26 ns .. 64.72 ns)
benchmarking attoparsec/radix compressed
time 5.068 μs (5.058 μs .. 5.077 μs)
1.000 R² (1.000 R² .. 1.000 R²)
mean 5.079 μs (5.066 μs .. 5.103 μs)
std dev 55.42 ns (34.22 ns .. 87.68 ns)
benchmarking attoparsec/naiive
time 69.88 μs (69.39 μs .. 70.51 μs)
1.000 R² (0.999 R² .. 1.000 R²)
mean 69.79 μs (69.53 μs .. 70.23 μs)
std dev 1.056 μs (811.4 ns .. 1.551 μs)
Benchmark radixtree-parsing: FINISH
```
A neat (and experimental) feature of `radixtree` is that it can compress trees
to use *only* the original corpus, as a single `Text` value, and simply store
the array offset/lengths into that original value for each node. See
`compressBy`.
name: radixtree
version: 0.4.0.0
description: A prefix-tree parsing library
homepage: https://gitlab.com/transportengineering/rnd/radixtree
license: BSD3
license-file: LICENSE
author: Mike Ledger
maintainer: mike@quasimal.com
copyright: 2016 Mike Ledger
copyright: 2018 Mike Ledger
category: Web
build-type: Simple
cabal-version: >=1.10
......
......@@ -194,7 +194,7 @@ instance NFData CompressedRadixTree where
instance NFData CompressedRadixTree1 where
{-# INLINE rnf #-}
rnf (CompressedRadixAccept ts v) = ts `seq` rnf v
rnf (CompressedRadixSkip v) = rnf v
rnf (CompressedRadixSkip v) = rnf v
-- | 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment