Popularity
8.7
Growing
Activity
4.7
-
66
6
5

Monthly Downloads: 462
Programming language: Haskell
License: Mozilla Public License 2.0
Tags: Data     Data Structures     Types    
Latest version: v0.3.3.0

typerep-map alternatives and similar packages

Based on the "Data" category

Do you think we are missing an alternative of typerep-map or a related project?

Add another 'Data' Package

README

typerep-map

logo

GitHub CI Build status Windows build status Hackage Stackage LTS Stackage Nightly [MPL-2.0 license](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

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.2 ghc-8.4.3 ghc-8.8.3 ghc-8.10.1
DMap TypeRep 517.5 ns 779.9 ns 1.559 μs 1.786 μs
typerep-map 205.3 ns 187.2 ns 190.1 ns 169.1 ns
ghc-8.2.2 ghc-8.4.3
DMap 8.2.2 DMap 8.4.3
TMap 8.2.2 TMap 8.4.3


*Note that all licence references and agreements mentioned in the typerep-map README section above are relevant to that project's source code only.