haskus-binary-1.5: Haskus binary format manipulation

Safe HaskellNone
LanguageHaskell2010

Haskus.Binary.Vector

Description

Vector with size in the type

Synopsis

Documentation

data Vector (n :: Nat) a Source #

Vector with type-checked size

Constructors

Vector Buffer 
Instances
(KnownNat n, Storable a, Eq a) => Eq (Vector n a) Source # 
Instance details

Defined in Haskus.Binary.Vector

Methods

(==) :: Vector n a -> Vector n a -> Bool #

(/=) :: Vector n a -> Vector n a -> Bool #

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

Defined in Haskus.Binary.Vector

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 # 
Instance details

Defined in Haskus.Binary.Vector

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 # 
Instance details

Defined in Haskus.Binary.Vector

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 #

(Storable a, ShiftableBits a, Bitwise a, FiniteBits a, KnownNat (BitSize a), KnownNat (n * BitSize a), KnownNat n) => ShiftableBits (Vector n a) Source # 
Instance details

Defined in Haskus.Binary.Vector

Methods

shiftR :: Vector n a -> Word -> Vector n a Source #

shiftL :: Vector n a -> Word -> Vector n a Source #

uncheckedShiftR :: Vector n a -> Word -> Vector n a Source #

uncheckedShiftL :: Vector n a -> Word -> Vector n a Source #

shift :: Vector n a -> Int -> Vector n a Source #

uncheckedShift :: Vector n a -> Int -> Vector n a Source #

(KnownNat (BitSize a), FiniteBits a, KnownNat n, Storable a) => FiniteBits (Vector n a) Source # 
Instance details

Defined in Haskus.Binary.Vector

Associated Types

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

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

Defined in Haskus.Binary.Vector

Methods

(.&.) :: Vector n a -> Vector n a -> Vector n a Source #

(.|.) :: Vector n a -> Vector n a -> Vector n a Source #

xor :: Vector n a -> Vector n a -> Vector n a Source #

(Storable a, Bits a, KnownNat n, KnownNat (n * BitSize a)) => RotatableBits (Vector n a) Source # 
Instance details

Defined in Haskus.Binary.Vector

Methods

rotate :: Vector n a -> Int -> Vector n a Source #

rotateL :: Vector n a -> Word -> Vector n a Source #

rotateR :: Vector n a -> Word -> Vector n a Source #

uncheckedRotate :: Vector n a -> Int -> Vector n a Source #

uncheckedRotateL :: Vector n a -> Word -> Vector n a Source #

uncheckedRotateR :: Vector n a -> Word -> Vector n a Source #

(Storable a, IndexableBits a, FiniteBits a, KnownNat (BitSize a), KnownNat n, Bitwise a) => IndexableBits (Vector n a) Source # 
Instance details

Defined in Haskus.Binary.Vector

Methods

bit :: Word -> Vector n a Source #

setBit :: Vector n a -> Word -> Vector n a Source #

clearBit :: Vector n a -> Word -> Vector n a Source #

complementBit :: Vector n a -> Word -> Vector n a Source #

testBit :: Vector n a -> Word -> Bool Source #

popCount :: Vector n a -> Word Source #

type SizeOf (Vector n a) Source # 
Instance details

Defined in Haskus.Binary.Vector

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

Defined in Haskus.Binary.Vector

type Alignment (Vector n a) = Alignment a
type BitSize (Vector n a) Source # 
Instance details

Defined in Haskus.Binary.Vector

type BitSize (Vector n a) = n * BitSize a

vectorBuffer :: Vector n a -> Buffer Source #

Return the buffer backing the vector

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

Reverse a 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

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 Source #

Concat several vectors into a single one

zipWith :: (KnownNat n, Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector n a -> Vector n b -> Vector n c Source #

Zip two vectors