Safe Haskell | None |
---|---|
Language | Haskell2010 |
Vector with size in the type
Synopsis
- data Vector (n :: Nat) a = Vector Buffer
- vectorBuffer :: Vector n a -> Buffer
- vectorReverse :: (KnownNat n, Storable a) => Vector n a -> Vector n a
- take :: forall n m a. KnownNat (SizeOf a * n) => Vector (m + n) a -> Vector n a
- drop :: forall n m a. KnownNat (SizeOf a * n) => Vector (m + n) a -> Vector m a
- index :: forall i a n. (KnownNat (ElemOffset a i n), Storable a) => Vector n a -> a
- fromList :: forall a (n :: Nat). (KnownNat n, Storable a) => [a] -> Maybe (Vector n a)
- fromFilledList :: forall a (n :: Nat). (KnownNat n, Storable a) => a -> [a] -> Vector n a
- fromFilledListZ :: forall a (n :: Nat). (KnownNat n, Storable a) => a -> [a] -> Vector n a
- toList :: forall a (n :: Nat). (KnownNat n, Storable a) => Vector n a -> [a]
- replicate :: forall a (n :: Nat). (KnownNat n, Storable a) => a -> Vector n a
- concat :: forall l (n :: Nat) a. (n ~ WholeSize l, KnownNat n, Storable a, StaticStorable a, HFoldr StoreVector (IO (Ptr a)) l (IO (Ptr a))) => HList l -> Vector n a
- zipWith :: (KnownNat n, Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector n a -> Vector n b -> Vector n c
Documentation
data Vector (n :: Nat) a Source #
Vector with type-checked size
Instances
vectorBuffer :: Vector n a -> Buffer Source #
Return the buffer backing the vector
take :: forall n m a. KnownNat (SizeOf a * n) => Vector (m + n) a -> Vector n a Source #
Yield the first n elements
drop :: forall n m a. KnownNat (SizeOf a * n) => Vector (m + n) a -> Vector m a Source #
Drop the first n elements
index :: forall i a n. (KnownNat (ElemOffset a i n), Storable a) => Vector n a -> a Source #
O(1) Index safely into the vector using a type level index.
fromList :: forall a (n :: Nat). (KnownNat n, Storable a) => [a] -> Maybe (Vector n a) Source #
Convert a list into a vector if the number of elements matches
fromFilledList :: forall a (n :: Nat). (KnownNat n, Storable a) => a -> [a] -> Vector n a Source #
Take at most n element from the list, then use z
fromFilledListZ :: forall a (n :: Nat). (KnownNat n, Storable a) => a -> [a] -> Vector n a Source #
Take at most (n-1) element from the list, then use z
toList :: forall a (n :: Nat). (KnownNat n, Storable a) => Vector n a -> [a] Source #
Convert a vector into a list
replicate :: forall a (n :: Nat). (KnownNat n, Storable a) => a -> Vector n a Source #
Create a vector by replicating a value