Portability | non-portable |
---|---|
Maintainer | Roman Leshchinskiy <rl@cse.unsw.edu.au> |
Safe Haskell | Safe-Infered |
Primitive operations on ByteArrays
- data ByteArray = ByteArray ByteArray#
- data MutableByteArray s = MutableByteArray (MutableByteArray# s)
- data ByteArray#
- data MutableByteArray# a
- newByteArray :: PrimMonad m => Int -> m (MutableByteArray (PrimState m))
- newPinnedByteArray :: PrimMonad m => Int -> m (MutableByteArray (PrimState m))
- newAlignedPinnedByteArray :: PrimMonad m => Int -> Int -> m (MutableByteArray (PrimState m))
- readByteArray :: (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> m a
- writeByteArray :: (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> a -> m ()
- indexByteArray :: Prim a => ByteArray -> Int -> a
- unsafeFreezeByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> m ByteArray
- unsafeThawByteArray :: PrimMonad m => ByteArray -> m (MutableByteArray (PrimState m))
- sizeofByteArray :: ByteArray -> Int
- sizeofMutableByteArray :: MutableByteArray s -> Int
- sameMutableByteArray :: MutableByteArray s -> MutableByteArray s -> Bool
- byteArrayContents :: ByteArray -> Addr
- mutableByteArrayContents :: MutableByteArray s -> Addr
- copyByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> ByteArray -> Int -> Int -> m ()
- copyMutableByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> MutableByteArray (PrimState m) -> Int -> Int -> m ()
- moveByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> MutableByteArray (PrimState m) -> Int -> Int -> m ()
- fillByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> Word8 -> m ()
- memcpyByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> MutableByteArray (PrimState m) -> Int -> Int -> m ()
- memcpyByteArray' :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> ByteArray -> Int -> Int -> m ()
- memmoveByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> MutableByteArray (PrimState m) -> Int -> Int -> m ()
- memsetByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Word8 -> Int -> m ()
Documentation
data MutableByteArray s Source
Mutable byte arrays associated with a primitive state token
data ByteArray#
data MutableByteArray# a
newByteArray :: PrimMonad m => Int -> m (MutableByteArray (PrimState m))Source
Create a new mutable byte array of the specified size.
newPinnedByteArray :: PrimMonad m => Int -> m (MutableByteArray (PrimState m))Source
Create a pinned byte array of the specified size. The garbage collector is guaranteed not to move it.
newAlignedPinnedByteArray :: PrimMonad m => Int -> Int -> m (MutableByteArray (PrimState m))Source
Create a pinned byte array of the specified size and with the give alignment. The garbage collector is guaranteed not to move it.
readByteArray :: (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> m aSource
Read a primitive value from the byte array. The offset is given in
elements of type a
rather than in bytes.
writeByteArray :: (Prim a, PrimMonad m) => MutableByteArray (PrimState m) -> Int -> a -> m ()Source
Write a primitive value to the byte array. The offset is given in
elements of type a
rather than in bytes.
indexByteArray :: Prim a => ByteArray -> Int -> aSource
Read a primitive value from the byte array. The offset is given in
elements of type a
rather than in bytes.
unsafeFreezeByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> m ByteArraySource
Convert a mutable byte array to an immutable one without copying. The array should not be modified after the conversion.
unsafeThawByteArray :: PrimMonad m => ByteArray -> m (MutableByteArray (PrimState m))Source
Convert an immutable byte array to a mutable one without copying. The original array should not be used after the conversion.
sizeofByteArray :: ByteArray -> IntSource
Size of the byte array.
sizeofMutableByteArray :: MutableByteArray s -> IntSource
Size of the mutable byte array.
sameMutableByteArray :: MutableByteArray s -> MutableByteArray s -> BoolSource
Check if the two arrays refer to the same memory block.
byteArrayContents :: ByteArray -> AddrSource
Yield a pointer to the array's data. This operation is only safe on
pinned byte arrays allocated by newPinnedByteArray
or
newAlignedPinnedByteArray
.
mutableByteArrayContents :: MutableByteArray s -> AddrSource
Yield a pointer to the array's data. This operation is only safe on
pinned byte arrays allocated by newPinnedByteArray
or
newAlignedPinnedByteArray
.
:: PrimMonad m | |
=> MutableByteArray (PrimState m) | destination array |
-> Int | offset into destination array |
-> ByteArray | source array |
-> Int | offset into source array |
-> Int | number of bytes to copy |
-> m () |
Copy a slice of an immutable byte array to a mutable byte array.
:: PrimMonad m | |
=> MutableByteArray (PrimState m) | destination array |
-> Int | offset into destination array |
-> MutableByteArray (PrimState m) | source array |
-> Int | offset into source array |
-> Int | number of bytes to copy |
-> m () |
Copy a slice of a mutable byte array into another array. The two slices may not overlap.
:: PrimMonad m | |
=> MutableByteArray (PrimState m) | destination array |
-> Int | offset into destination array |
-> MutableByteArray (PrimState m) | source array |
-> Int | offset into source array |
-> Int | number of bytes to copy |
-> m () |
Copy a slice of a mutable byte array into another, potentially overlapping array.
:: PrimMonad m | |
=> MutableByteArray (PrimState m) | array to fill |
-> Int | offset into array |
-> Int | number of bytes to fill |
-> Word8 | value to fill with |
-> m () |
Fill a slice of a mutable byte array with a value.
Deprecated operations
memcpyByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> MutableByteArray (PrimState m) -> Int -> Int -> m ()Source
memcpyByteArray' :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> ByteArray -> Int -> Int -> m ()Source
memmoveByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> MutableByteArray (PrimState m) -> Int -> Int -> m ()Source
memsetByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Word8 -> Int -> m ()Source