total-map-0.0.1: Finitely represented /total/ maps




Finitely represented total maps. Represented by as a partial map and a default value. Has Applicative and Monad instances (unlike Data.Map).



data TMap k v Source

Total map


Ord k => Monad (TMap k) 
Functor (TMap k) 
Ord k => Applicative (TMap k) 

(!) :: Ord k => TMap k v -> k -> vSource

Sample a total map. Semantic function.

tabulate :: Eq k => v -> Set k -> (k -> v) -> TMap k vSource

Construct a total map, given a default value, a set of keys, and a function to sample over that set. You might want to trim the result.

trim :: (Ord k, Eq v) => TMap k v -> TMap k vSource

Optimize a TMap, weeding out any explicit default values. A semantic no-op, i.e., (!) . trim == (!).