total-map: Finitely represented total maps

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

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


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.0, 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.1.0, 0.1.3
Change log ChangeLog.md
Dependencies base (<5), containers, semiring-num (>=1.6.0.4) [details]
License BSD-3-Clause
Copyright (c) 2012--2019 by Conal Elliott
Author Conal Elliott
Maintainer conal@conal.net
Category Data
Home page http://github.com/conal/total-map/
Source repo head: git clone git://github.com/conal/total-map.git
Uploaded by ConalElliott at 2019-11-23T22:02:17Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 7124 total (58 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-11-23 [all 1 reports]

Readme for total-map-0.1.3

[back to package description]

The usual finite map type (Map from Data.Map) is not an applicative functor, as it doesn't have a pure. Consequently, it's also not a monad. On the other hand, we can decompose Map into two parts: a total map, and Maybe, i.e.,

type Map k v = TMap k (Maybe v)

The type TMap of total maps does have Applicative and Monad instances, and hence this hypothetically rebuilt Map would as well.

The idea for TMap is introduced in the paper Denotational design with type class morphisms. The meaning Map k v is given by its semantic function

(!) :: Map k v -> (k -> v)

The type class morphism (TCM) principle then exactly dictates the meanings of several class instances for TMap, including Functor, Applicative, Monad, and Monoid. For instance, (!) must be a monoid (homo)morphism, i.e.,

(!) mempty == mempty
(!) (s `mappend` t) == (!) s `mappend` (!) t

The current implementation of TMap is via Data.Map.