Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- withVec :: forall a b d. Storable b => (a -> (b -> IO d) -> IO d) -> Vector a -> (Ptr b -> IO d) -> IO d
- withArray :: forall a b d. (a -> (b -> IO d) -> IO d) -> Vector a -> (Vector b -> IO d) -> IO d
- withSizedArray :: forall a b d n. (a -> (b -> IO d) -> IO d) -> Vector n a -> (Vector n b -> IO d) -> IO d
- byteStringToSizedVector :: forall n v. (KnownNat n, Vector v Word8) => ByteString -> Vector v n Word8
- byteStringToNullTerminatedSizedVector :: forall n v. (KnownNat n, 1 <= n, Vector v CChar) => ByteString -> Vector v n CChar
- padSized :: forall n a v. (KnownNat n, Vector v a) => a -> v a -> Vector v n a
- padVector :: Vector v a => a -> Int -> v a -> v a
- packCStringElemOff :: Ptr (Ptr CChar) -> Int -> IO ByteString
- pokeFixedLengthByteString :: forall n. KnownNat n => Ptr (Vector n Word8) -> ByteString -> IO ()
- pokeFixedLengthNullTerminatedByteString :: forall n. KnownNat n => Ptr (Vector n CChar) -> ByteString -> IO ()
- peekByteStringFromSizedVectorPtr :: forall n. KnownNat n => Ptr (Vector n Word8) -> IO ByteString
- lowerArrayPtr :: forall a n. Ptr (Vector n a) -> Ptr a
- advancePtrBytes :: Ptr a -> Int -> Ptr a
Documentation
withVec :: forall a b d. Storable b => (a -> (b -> IO d) -> IO d) -> Vector a -> (Ptr b -> IO d) -> IO d Source #
withArray :: forall a b d. (a -> (b -> IO d) -> IO d) -> Vector a -> (Vector b -> IO d) -> IO d Source #
withSizedArray :: forall a b d n. (a -> (b -> IO d) -> IO d) -> Vector n a -> (Vector n b -> IO d) -> IO d Source #
byteStringToSizedVector :: forall n v. (KnownNat n, Vector v Word8) => ByteString -> Vector v n Word8 Source #
Convert a bytestring to a sized vector. If the bytestring is too long it will be truncated. If it is too short it will be zero padded
byteStringToNullTerminatedSizedVector :: forall n v. (KnownNat n, 1 <= n, Vector v CChar) => ByteString -> Vector v n CChar Source #
Convert a bytestring to a null terminated sized vector. If the bytestring is too long it will be truncated.
:: (KnownNat n, Vector v a) | |
=> a | The value with which to pad if the given vector is too short |
-> v a | The vector to pad or truncate |
-> Vector v n a |
Pad or truncate a vector so that it has the required size
padVector :: Vector v a => a -> Int -> v a -> v a Source #
Make sure a vector is at least a certain length
packCStringElemOff :: Ptr (Ptr CChar) -> Int -> IO ByteString Source #
pokeFixedLengthByteString :: forall n. KnownNat n => Ptr (Vector n Word8) -> ByteString -> IO () Source #
Store a ByteString
in a fixed amount of space, truncating if necessary.
If the ByteString
is not long enough to fill the space the remaining
bytes are unchanged
pokeFixedLengthNullTerminatedByteString :: forall n. KnownNat n => Ptr (Vector n CChar) -> ByteString -> IO () Source #
Store a ByteString
in a fixed amount of space inserting a null
character at the end and truncating if necessary.
If the ByteString
is not long enough to fill the space the remaining
bytes are unchanged
Note that if the ByteString
is exactly long enough the last byte will
still be replaced with 0
peekByteStringFromSizedVectorPtr :: forall n. KnownNat n => Ptr (Vector n Word8) -> IO ByteString Source #