data-inttrie-0.0.2: A lazy, infinite trie of integers.

PortabilityHaskell 2010
MaintainerLuke Palmer <>



Provides a minimal infinite, lazy trie for integral types. It intentionally leaves out ideas such as delete and emptiness so that it can be used lazily, eg. as the target of an infinite foldr. Essentially its purpose is to be an efficient implementation of a function from integral type, given point-at-a-time modifications.



data IntTrie a Source

A trie from integers to values of type a.

Semantics: [[IntTrie a]] = Integer -> a

identity :: Bits a => IntTrie aSource

The identity trie.

 apply identity = id

apply :: (Ord b, Bits b) => IntTrie a -> b -> aSource

Apply the trie to an argument. This is the semantic map.

modify :: (Ord b, Bits b) => b -> (a -> a) -> IntTrie a -> IntTrie aSource

Modify the function at one point

 apply (modify x f t) i | i == x = f (apply t i)
                        | otherwise = apply t i

overwrite :: (Ord b, Bits b) => b -> a -> IntTrie a -> IntTrie aSource

Overwrite the function at one point

 overwrite i x = modify i (const x)