regex-tdfa-1.2.1: Replaces/Enhances Text.Regex

Safe Haskell | Safe
Language | Haskell98

Text.Regex.TDFA.IntArrTrieSet

Description

This creates a lazy Trie based on a finite range of Ints and is used to memorize a function over the subsets of this range.

To create a Trie you need two supply 2 things * Range of keys to bound * A function or functions used to construct the value for a subset of keys

The Trie uses the Array type internally.

Synopsis

- data TrieSet v = TrieSet {
  - value :: v
  - next :: Array Int (TrieSet v)
  }
- lookupAsc :: TrieSet v -> [Int] -> v
- fromBounds :: (Int, Int) -> ([Int] -> v) -> TrieSet v
- fromSinglesMerge :: v -> (v -> v -> v) -> (Int, Int) -> (Int -> v) -> TrieSet v
- fromSinglesSum :: ([v] -> v) -> (Int, Int) -> (Int -> v) -> TrieSet v

# Documentation

data TrieSet v #

Constructors

TrieSet |
Fields value :: v next :: Array Int (TrieSet v)

lookupAsc :: TrieSet v -> [Int] -> v #

This is the accessor for the Trie. The list of keys should be sorted.

fromBounds #

Arguments

:: (Int, Int) | (lower,upper) range of keys, lower<=upper
-> ([Int] -> v) | Function from list of keys to its value. It must work for distinct ascending lists.
-> TrieSet v | The constructed Trie

This is a Trie constructor for a complete range of keys.

fromSinglesMerge #

Arguments

:: v | value for (lookupAsc trie [])
-> (v -> v -> v) | merge operation on values
-> (Int, Int) | (lower,upper) range of keys, lower<=upper
-> (Int -> v) | Function from a single key to its value
-> TrieSet v | The constructed Trie

This is a Trie constructor for a complete range of keys that uses a function from single values and a merge operation on values to fill the Trie.

fromSinglesSum #

Arguments

:: ([v] -> v) | summation operation for values
-> (Int, Int) | (lower,upper) range of keys, lower <= upper
-> (Int -> v) | Function from a single key to its value
-> TrieSet v | The constructed Trie

This is a Trie constructor for a complete range of keys that uses a function from single values and a sum operation of values to fill the Trie.