GitPedia

Typerep map

⚡️Efficient implementation of Map with types as keys

From kowainik·Updated January 14, 2026·View on GitHub·

`typerep-map` introduces `TMap` and `TypeRepMap` — data structures like [`Map`](http://hackage.haskell.org/package/containers-0.6.0.1/docs/Data-Map-Lazy.html#t:Map), but where types serve as keys, and values have the types specified in the corresponding key spots. The project is written primarily in Haskell, distributed under the Mozilla Public License 2.0 license, first published in 2017. Key topics include: arrays, binary-search, cache, dependent-map, dmap.

Latest release: v0.7.0.0
January 14, 2026View Changelog →

typerep-map

logo

GitHub CI
Hackage
MPL-2.0 license

typerep-map introduces TMap and TypeRepMap — data structures like Map, but where types serve as keys, and values have the types specified in the corresponding key spots.

For the more details on the implementation see the following blog post:

Usage example

haskell
ghci> import Data.TMap ghci> tm = insert True $ one (42 :: Int) ghci> size tm 2 ghci> res = lookup tm ghci> res :: Maybe Int Just 42 ghci> res :: Maybe Bool Just True ghci> res :: Maybe String Nothing ghci> lookup (insert "hello" tm) :: Maybe String Just "hello" ghci> member @Int tm True ghci> tm' = delete @Int tm ghci> member @Int tm' False

Benchmarks

Tables below contain comparision with DMap TypeRep of ten lookup operations
on structure with size 10^4:

ghc-8.2.2ghc-8.4.3ghc-8.8.3ghc-8.10.1
DMap TypeRep517.5 ns779.9 ns1.559 μs1.786 μs
typerep-map205.3 ns187.2 ns190.1 ns169.1 ns
ghc-8.2.2ghc-8.4.3
DMap 8.2.2DMap 8.4.3
TMap 8.2.2TMap 8.4.3

Contributors

Showing top 11 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from kowainik/typerep-map via the GitHub API.Last fetched: 6/16/2026