functor-combo-0.0.8: Functor combinators with tries & zippers

Stabilityexperimental
Maintainerconal@conal.net
Safe HaskellNone

FunctorCombo.StrictMemo

Description

Functor-based memo tries (strict for now)

Synopsis

Documentation

class HasTrie k whereSource

Domain types with associated memo tries

Associated Types

type Trie k :: * -> *Source

Representation of trie with domain type a

Methods

trie :: (k -> v) -> k :->: vSource

Create the trie for the entire domain of a function

untrie :: (k :->: v) -> k -> vSource

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

enumerate :: (k :->: v) -> [(k, v)]Source

List the trie elements. Order of keys (:: k) is always the same.

Instances

HasTrie Bool 
HasTrie Int 
HasTrie Integer 
HasTrie () 
(HasTrie a, Functor (Trie a)) => HasTrie [a] 
HasTrie a => HasTrie (Id a) 
(HasTrie a, Functor (Trie a)) => HasTrie (Tree a) 
(HasTrie a, HasTrie (:->: a b)) => HasTrie (a -> b) 
(HasTrie a, HasTrie b) => HasTrie (Either a b) 
(HasTrie a, Functor (Trie a), HasTrie b) => HasTrie (a, b) 
HasTrie x => HasTrie (Const x a) 
(HasTrie a, Functor (Trie a), HasTrie b, Functor (Trie b), HasTrie c) => HasTrie (a, b, c) 
HasTrie (g (f a)) => HasTrie (:. g f a) 
(HasTrie (f a), HasTrie (g a)) => HasTrie (:+: f g a) 
(HasTrie (f a), Functor (Trie (f a)), HasTrie (g a)) => HasTrie (:*: f g a) 
(HasTrie a, Functor (Trie a), HasTrie b, Functor (Trie b), HasTrie c, Functor (Trie c), HasTrie d) => HasTrie (a, b, c, d) 

type :->: k v = Trie k vSource

Memo trie from k to v

memo :: HasTrie k => Unop (k -> v)Source

Trie-based function memoizer

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

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) => Unop (r -> s -> t -> a)Source

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