haskus-system-0.6.0.0: Haskus system programming framework

Safe HaskellNone
LanguageHaskell2010

Haskus.Format.Binary.Vector

Description

Vector with size in the type

Synopsis

Documentation

data Vector n a Source #

Vector with type-checked size

Constructors

Vector Buffer 

Instances

(Storable a, Show a, KnownNat n) => Show (Vector n a) Source # 

Methods

showsPrec :: Int -> Vector n a -> ShowS #

show :: Vector n a -> String #

showList :: [Vector n a] -> ShowS #

(KnownNat n, Storable a) => Storable (Vector n a) Source # 

Methods

peekIO :: Ptr (Vector n a) -> IO (Vector n a) Source #

pokeIO :: Ptr (Vector n a) -> Vector n a -> IO () Source #

alignment :: Vector n a -> Word Source #

sizeOf :: Vector n a -> Word Source #

KnownNat (* (SizeOf a) n) => StaticStorable (Vector n a) Source # 

Associated Types

type SizeOf (Vector n a) :: Nat Source #

type Alignment (Vector n a) :: Nat Source #

Methods

staticPeekIO :: Ptr (Vector n a) -> IO (Vector n a) Source #

staticPokeIO :: Ptr (Vector n a) -> Vector n a -> IO () Source #

type SizeOf (Vector n a) Source # 
type SizeOf (Vector n a) = * (SizeOf a) n
type Alignment (Vector n a) Source # 
type Alignment (Vector n a) = Alignment a

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. (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. (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. (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. (KnownNat n, Storable a) => Vector n a -> [a] Source #

Convert a vector into a list

replicate :: forall a n. (KnownNat n, Storable a) => a -> Vector n a Source #

Create a vector by replicating a value

concat :: forall l n a. (n ~ WholeSize l, KnownNat n, Storable a, StaticStorable a, HFoldr StoreVector (IO (Ptr a)) l (IO (Ptr a))) => HList l -> Vector n a Source #

Concat several vectors into a single one