Copyright | (c) Conal Elliott 2010-2012 |
---|---|
License | BSD3 |
Maintainer | conal@conal.net |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
Functor-based memo tries (strict for now)
- class Functor (Trie k) => HasTrie k where
- type (:->:) k v = Trie k v
- (!) :: HasTrie k => (k :->: v) -> k -> v
- memo :: HasTrie k => Unop (k -> v)
- memo2 :: (HasTrie s, HasTrie t) => Unop (s -> t -> a)
- memo3 :: (HasTrie r, HasTrie s, HasTrie t) => Unop (r -> s -> t -> a)
- idTrie :: HasTrie k => k :->: k
- onUntrie :: (HasTrie a, HasTrie b) => ((a -> a') -> b -> b') -> (a :->: a') -> b :->: b'
- onUntrie2 :: (HasTrie a, HasTrie b, HasTrie c) => ((a -> a') -> (b -> b') -> c -> c') -> (a :->: a') -> (b :->: b') -> c :->: c'
- data TrieTree :: * -> * -> * -> * where
Documentation
class Functor (Trie k) => HasTrie k where Source
Domain types with associated memo tries
trie :: (k -> v) -> k :->: v Source
Create the trie for the entire domain of a function
untrie :: (k :->: v) -> k -> v Source
Convert k trie to k function, i.e., access k field of the trie
HasTrie Bool | |
HasTrie Int | |
HasTrie Integer | |
HasTrie () | |
HasTrie a => HasTrie [a] | |
HasTrie a => HasTrie (Id a) | |
HasTrie a => HasTrie (Tree a) | |
HasTrie a => HasTrie (Pair a) | |
(HasTrie a, HasTrie ((:->:) a b)) => HasTrie (a -> b) | |
(HasTrie a, HasTrie b) => HasTrie (Either a b) | |
(HasTrie a, HasTrie b) => HasTrie (a, b) | |
HasTrie x => HasTrie (Const x a) | |
(HasTrie k, Functor (Trie k), IsNat n) => HasTrie (Vec n k) | |
(HasTrie a, HasTrie 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), HasTrie (g a)) => HasTrie ((:*:) f g a) | |
(HasTrie a, HasTrie b, HasTrie c, HasTrie d) => HasTrie (a, b, c, d) |
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.
onUntrie2 :: (HasTrie a, HasTrie b, HasTrie c) => ((a -> a') -> (b -> b') -> c -> c') -> (a :->: a') -> (b :->: b') -> c :->: c' Source