Home

Awesome

compactmap

Haskell-CI compactmap on Stackage LTS compactmap on Stackage Nightly

Memory efficient read-only key-value stores. It is built by sorting the input list and converting it to a Vector. This module also exports a generic version that works like the one in Vector.

Example usage:

module Main where

import qualified Data.CompactMap as CM

kvlist :: [(String, Int)]
kvlist = zip (map return ['a' .. 'z']) [5..]

main :: IO ()
main = do
    let compactmap = CM.fromList kvlist fst
    print (CM.lookup "b" compactmap)
    print (CM.lookup "aa" compactmap)