Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data TypeVector d
- empty :: TypeVector '[]
- index :: forall a d. KnownNat (Index a d) => TypeVector d -> Lookup a d
- cons :: forall a d b. b -> TypeVector d -> TypeVector ('(a, b) ': d)
- (<|) :: forall a d b. b -> TypeVector d -> TypeVector ('(a, b) ': d)
- snoc :: forall a d b. Last d ~ '(a, b) => TypeVector (Init d) -> b -> TypeVector d
- (|>) :: forall a d b. Last d ~ '(a, b) => TypeVector (Init d) -> b -> TypeVector d
- toList :: TypeVector d -> TypeList l
Documentation
data TypeVector d Source #
Vector-backed type-map.
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
.
toList :: TypeVector d -> TypeList l Source #
Convert from a vector to a list.