MemoTrie-0.2: 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

Mapping from all elements of a to the results of some function

Associated Types

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

Representation of trie with domain type a

Methods

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

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

Convert a trie to a function, i.e., access a field of the trie

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.