Mutable variable with primitive value.
Modulepvar-1.0.0.0Haskell2010
Data.Primitive.PVar.Unsafe
- 1 type
- 25 values
- Packagepvar-1.0.0.0
- Exports26
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceInternal.hs
Creation
5 declarationsCreate a mutable variable in unpinned and unititialized memory
Create a mutable variable in pinned memory with uninitialized memory.
Create a mutable variable in pinned uninitialized memory.
Create a mutable variable in pinned uninitialized memory using Storable interface for getting the number of bytes for memory allocation.
Create a mutable variable in pinned uninitialized memory using Storable interface for getting the number of bytes for memory allocation and alignement.
Access
2 declarationsUse Storable reading functionality inside the PrimMonad.
Use Storable wrting functionality inside the PrimMonad.
Conversion
3 declarationsExtract the address to the mutable variable, but only if it is backed by pinned
memory. It is unsafe because even for pinned memory memory can be deallocated if
associated PVar goes out of scope. Use withPtrPVar or
Data.Primitive.PVar.toForeignPtr instead.
Get the address to the contents. This is highly unsafe, espcially if memory is not pinned
Convert PVar into a ForeignPtr, very unsafe if not backed by pinned memory.
Reset
1 declarationReset contents of a mutable variable to zero.
Unpacked opartions
3 declarationsGet the size of the mutable variable in bytes as an unpacked integer
Get the alignment of the mutable variable in bytes as an unpacked integer
Fill the contents of mutable variable with byte c
ByteArray
0 declarationsAtomic operations
atomicModifyIntArray# :: MutableByteArray# dArray to be mutated
-> Int#Index in number of Int# elements into the MutableByteArray#
-> (Int# -> (# Int#, b #))Function to be applied atomically to the element
-> State# dStarting state
-> (# State# d, b #)
Using casIntArray# perform atomic modification of an integer element in a MutableByteArray#. Implies a full memory barrier.
atomicModifyIntArray_# :: MutableByteArray# dArray to be mutated
-> Int#Index in number of Int# elements into the MutableByteArray#
-> (Int# -> Int#)Function to be applied atomically to the element
-> State# dStarting state
-> State# d
Uses casIntArray# to perform atomic modification of an integer element in a MutableByteArray#. Implies a full memory barrier.
Memory copying
Copy the value from a frozen ByteArray into a mutable variable at specified index. Index of array is not checked and can result in an unchecked exception when incorrect
copyFromMutableByteArrayPVar :: (MonadPrim s m, Prim a)=> MutableByteArray s-> IntOffset in number of elements into the array
-> PVar a s-> m ()
Copy the value from MutableByteArray at specified index into the mutable variable. Index of array is not checked and can result in an unchecked exception when incorrect
copyPVarToMutableByteArray :: (MonadPrim s m, Prim a)=> PVar a s-> MutableByteArray s-> IntOffset in number of elements into the array
-> m ()
Copy the value from a mutable variable into a mutable array at the specified index. Index of array is not checked and can result in an unchecked exception when incorrect
Check if memory is pinned
Check whether or not the ByteArray is pinned.
Note - This function uses GHC built-in functions for GHC 8.2 and newer, but for older versions it fallsback onto custom implementation.
Check whether or not the MutableByteArray is pinned.
Note - This function uses GHC built-in functions for GHC 8.2 and newer, but for older versions it fallsback onto custom implementation.
Primitive versions
Determine whether a ByteArray# is guaranteed not to move.
Determine whether a MutableByteArray# is guaranteed not to move
during GC.
Helpers
2 declarationsShow the type name
Unwrap the primitive Int