type-map-0.1.7.0: Type-indexed maps
Safe HaskellNone
LanguageHaskell2010

Data.TypeMap.List

Synopsis

Documentation

data TypeList d Source #

List-backed type-map.

empty :: TypeList '[] Source #

Empty list.

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

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

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

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

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

Add an element to the beginning of a list. O(1)

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

Synonym of cons.

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

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

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

Synonym of snoc.

toVector :: TypeList d -> TypeVector d Source #

Convert from a list to a vector.