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

Copyright(c) Luke Palmer 2010
LicenseBSD3
MaintainerLuke Palmer <lrpalmer@gmail.com>
Stabilityexperimental
PortabilityHaskell 2010
Safe HaskellSafe-Inferred
LanguageHaskell98

Data.IntTrie

Description

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.

Synopsis

Documentation

data IntTrie a

A trie from integers to values of type a.

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

identity :: (Num a, Bits a) => IntTrie a

The identity trie.

apply identity = id

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

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

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

Modify the function at one point

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

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

Modify the function at one point (strict version)

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

Overwrite the function at one point

overwrite i x = modify i (const x)