type-map-0.1.0.0: Type-indexed maps

Safe HaskellNone
LanguageHaskell2010

Data.TypeMap.Map

Synopsis

Documentation

data TypeMap d Source #

IntMap-backed type-map.

empty :: TypeMap '[] Source #

Empty vector.

index :: forall a d. KnownNat (Index a d) => TypeMap d -> Lookup a d Source #

Access an element indexed by type a. O(log n)

If a is associated to b in the type list d:

index @a (v :: TypeMap d) :: b
>>> let v = (0 :: Int) <| True <| "Hello" <| empty :: TypeMap '[ '("a", Int), '("b", Bool), '("c", String)]
>>> index @"c" v
"Hello"

cons :: forall a d b. b -> TypeMap d -> TypeMap ('(a, b) ': d) infixr 5 Source #

Add an element to the beginning of a map. O(log n)

(<|) :: forall a d b. b -> TypeMap d -> TypeMap ('(a, b) ': d) infixr 5 Source #

Synonym of cons.

snoc :: forall a d b. Last d ~ '(a, b) => TypeMap (Init d) -> b -> TypeMap d infixl 5 Source #

Add an element to the end of a list. O(log n)

(|>) :: forall a d b. Last d ~ '(a, b) => TypeMap (Init d) -> b -> TypeMap d infixl 5 Source #

Synonym of snoc.