word-trie-0.2.0.4: Implementation of a finite trie over words.

Portabilityportable
Stabilityexperimental
Maintainerfuuzetsu@fuuzetsu.co.uk
Safe HaskellNone

Data.Trie

Description

An implementation of a trie over a words. Properties:

 fromList . toListid
 toList . fromString ≡ (:[])
 sort . nub . toList . fromListsort . nub

Synopsis

Documentation

empty :: TrieSource

A blank Trie

insert :: String -> Trie -> TrieSource

Insert a new string into the trie.

fromList :: [String] -> TrieSource

Take a list of String and compress it into a Trie

toList :: Trie -> [String]Source

Take a trie and expand it into the strings that it represents

lookupPrefix :: MonadPlus m => String -> Trie -> m TrieSource

Takes a trie and a prefix and returns the sub-trie that of words with that prefix

forcedNext :: Trie -> StringSource

Finds the longest certain path down the trie starting at a the root Invariant Assumption: All paths have at least one true node below them

data Trie Source

Instances

possibleSuffixes :: String -> Trie -> [String]Source

Helper function, finds all the suffixes of a given prefix

certainSuffix :: String -> Trie -> StringSource

Helper function, finds the longest certain path down the trie starting at a given word