fixfile-0.2.0.0: File-backed recursive data structures.

Copyright(C) 2016 Rev. Johnny Healey
LicenseLGPL-3
MaintainerRev. Johnny Healey <rev.null@gmail.com>
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Data.FixFile.Trie

Description

This is a Trie data type that can be used with FixFile. It can be used as a key-value store where the key is a ByteString of arbitrary size.

Synopsis

Documentation

data Trie v a Source

Fixed (Trie v) is a trie mapping lazy ByteStrings to values of type v.

Instances

Functor (Trie v) Source 
Foldable (Trie v) Source 
Traversable (Trie v) Source 
(Read v, Read a) => Read (Trie v a) Source 
(Show v, Show a) => Show (Trie v a) Source 
Generic (Trie v a) Source 
(Binary v, Binary a) => Binary (Trie v a) Source 
type Rep (Trie v a) Source 

empty :: Fixed g => g (Trie v) Source

An empty Trie

freeze :: Fixed g => g (Trie v) -> g (Trie v) Source

freeze takes a Trie that has been mutated and creates a copy of it that allows for faster lookups. This happens automatically for Tries that are serialized to a FixFile. A Trie will be automatically thawed on any node that is modified.

createTrieFile :: (Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (Trie v))) Source

Create a FixFile of (Trie v) data.

openTrieFile :: (Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (Trie v))) Source

Open a FixFile of (Trie v) data.

lookupTrie :: Fixed g => ByteString -> g (Trie v) -> Maybe v Source

Lookup a possible value stored in a trie for a given ByteString key.

insertTrie :: Fixed g => ByteString -> v -> g (Trie v) -> g (Trie v) Source

Insert a value into a trie for the given ByteString key.

deleteTrie :: Fixed g => ByteString -> g (Trie v) -> g (Trie v) Source

Delete a value from a trie for a given ByteString key.

iterateTrie :: Fixed g => ByteString -> g (Trie v) -> [(ByteString, v)] Source

Iterate over a Trie for all of the ByteString and value tuples for a given ByteString prefix.

trieMap :: (Fixed h, Fixed i) => (v -> v') -> h (Trie v) -> i (Trie v') Source

Map a function over a Fixed Trie. Because of the data types used, this can't be implemented as a Functor.