enumfun- Finitely represented /total/ EnumMaps

Safe HaskellSafe-Inferred



Finitely represented total EnumMaps. Comprises a partial EnumMap and a default value. Has Applicative and Monad instances, unlike EnumMap.

Inspired by Conal's Data.TotalMap: http://hackage.haskell.org/package/total-map



data EnumFun k v Source

Total EnumMap.


EnumFun v (EnumMap k v)

Default value and a finite map.


Typeable2 EnumFun 
Enum k => Monad (EnumFun k) 
Functor (EnumFun k) 
(Functor (EnumFun k), Enum k) => Applicative (EnumFun k) 
Foldable (EnumFun k) 
(Functor (EnumFun k), Foldable (EnumFun k)) => Traversable (EnumFun k) 
Eq v => Eq (EnumFun k v) 
(Eq (EnumFun k v), Ord v) => Ord (EnumFun k v) 
(Enum k, Show k, Show v) => Show (EnumFun k v) 
(Enum k, Monoid v) => Monoid (EnumFun k v) 

(!) :: Enum k => EnumFun k v -> k -> vSource

Sample a total map. Semantic function.

trim :: Eq v => EnumFun k v -> EnumFun k vSource

Optimise an EnumFun, weeding out any explicit default values. A semantic no-op, i.e., (!) . trim == (!).

fromList :: Enum k => v -> [(k, v)] -> EnumFun k vSource

Create an EnumFun from a default value and a list of key/value pairs.

fromStrict :: EnumFun k v -> EnumFun k vSource

Convert from a Strict EnumFun. The operation is essentially free; we only needed two distinct types for the different class instances.