MemoTrie-0.0: Trie-based memo functions

Stabilityexperimental
Maintainerconal@conal.net

Data.MemoTrie

Description

Trie-based memoizer Adapted from sjanssen's paste: a lazy trie http://hpaste.org/3839.

Synopsis

Documentation

class HasTrie a whereSource

Associated Types

data :->: a :: * -> *Source

Methods

trie :: (a -> b) -> a :->: bSource

untrie :: (a :->: b) -> a -> bSource

Instances

HasTrie Bool 
HasTrie Int 
HasTrie Word 
HasTrie () 
HasTrie x => HasTrie [x] 
(HasTrie a, HasTrie b) => HasTrie (Either a b) 
(HasTrie a, HasTrie b) => HasTrie (a, b) 
(HasTrie a, HasTrie b, HasTrie c) => HasTrie (a, b, c) 

memo :: HasTrie t => (t -> a) -> t -> aSource

Trie-based function memoizer

memo2 :: (HasTrie s, HasTrie t) => (s -> t -> a) -> s -> t -> aSource

Memoize a binary function, on its first argument and then on its second. Take care to exploit any partial evaluation.

memo3 :: (HasTrie r, HasTrie s, HasTrie t) => (r -> s -> t -> a) -> r -> s -> t -> aSource

Memoize a ternary function on successive arguments. Take care to exploit any partial evaluation.

mup :: HasTrie t => (b -> c) -> (t -> b) -> t -> cSource

Lift a memoizer to work with one more argument.

trieBits :: Bits t => (t -> a) -> [Bool] :->: aSource

Handy for trie in a bits-based Trie instance

untrieBits :: Bits t => ([Bool] :->: a) -> t -> aSource

Handy for untrie in a bits-based Trie instance