type-map-0.1.0.0: Type-indexed maps

Safe HaskellNone
LanguageHaskell2010

Data.TypeMap.Internal.Vector

Synopsis

Documentation

newtype TypeVector d Source #

Vector-backed type-map.

Constructors

TypeVector (Vector Any) 

empty :: TypeVector '[] Source #

Empty vector.

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

Access an element indexed by type a. O(1)

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

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

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

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

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

Synonym of cons.

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

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

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

Synonym of snoc.