License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Give access to Array non public functions which can be used to make certains optimisations.
Most of what is available here has no guarantees of stability. Anything can be removed and changed.
- data UArray ty
- fromForeignPtr :: PrimType ty => (ForeignPtr ty, Int, Int) -> UArray ty
- withPtr :: (PrimMonad prim, PrimType ty) => UArray ty -> (Ptr ty -> prim a) -> prim a
- copyToPtr :: forall ty prim. (PrimType ty, PrimMonad prim) => UArray ty -> Ptr ty -> prim ()
- recast :: forall a b. (PrimType a, PrimType b) => UArray a -> UArray b
- toHexadecimal :: PrimType ty => UArray ty -> UArray Word8
- new :: (PrimMonad prim, PrimType ty) => CountOf ty -> prim (MUArray ty (PrimState prim))
- newPinned :: (PrimMonad prim, PrimType ty) => CountOf ty -> prim (MUArray ty (PrimState prim))
- withMutablePtr :: (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> (Ptr ty -> prim a) -> prim a
Documentation
An array of type built on top of GHC primitive.
The elements need to have fixed sized and the representation is a packed contiguous array in memory that can easily be passed to foreign interface
UVecBA !(Offset ty) !(CountOf ty) !PinnedStatus ByteArray# | |
UVecAddr !(Offset ty) !(CountOf ty) !(FinalPtr ty) |
PrimType ty => IsList (UArray ty) Source # | |
(PrimType ty, Eq ty) => Eq (UArray ty) Source # | |
Data ty => Data (UArray ty) Source # | |
(PrimType ty, Ord ty) => Ord (UArray ty) Source # | |
(PrimType ty, Show ty) => Show (UArray ty) Source # | |
PrimType ty => Monoid (UArray ty) Source # | |
NormalForm (UArray ty) Source # | |
PrimType ty => Copy (UArray ty) Source # | |
PrimType ty => Buildable (UArray ty) Source # | |
PrimType ty => Collection (UArray ty) Source # | |
PrimType ty => Foldable (UArray ty) Source # | |
PrimType ty => IndexedCollection (UArray ty) Source # | |
PrimType ty => InnerFunctor (UArray ty) Source # | |
PrimType ty => Sequential (UArray ty) Source # | |
PrimType ty => Zippable (UArray ty) Source # | |
PrimType a => Hashable (UArray a) Source # | |
type Item (UArray ty) Source # | |
type Element (UArray ty) Source # | |
type Mutable (UArray ty) Source # | |
type Step (UArray ty) Source # | |
fromForeignPtr :: PrimType ty => (ForeignPtr ty, Int, Int) -> UArray ty Source #
:: (PrimType ty, PrimMonad prim) | |
=> UArray ty | the source array to copy |
-> Ptr ty | The destination address where the copy is going to start |
-> prim () |
Copy all the block content to the memory starting at the destination address
recast :: forall a b. (PrimType a, PrimType b) => UArray a -> UArray b Source #
Recast an array of type a to an array of b
a and b need to have the same size otherwise this raise an async exception
Mutable facilities
new :: (PrimMonad prim, PrimType ty) => CountOf ty -> prim (MUArray ty (PrimState prim)) Source #
Create a new mutable array of size @n.
When memory for a new array is allocated, we decide if that memory region should be pinned (will not be copied around by GC) or unpinned (can be moved around by GC) depending on its size.
You can change the threshold value used by setting the environment variable
HS_FOUNDATION_UARRAY_UNPINNED_MAX
.
newPinned :: (PrimMonad prim, PrimType ty) => CountOf ty -> prim (MUArray ty (PrimState prim)) Source #
Create a new pinned mutable array of size @n.
all the cells are uninitialized and could contains invalid values.
All mutable arrays are allocated on a 64 bits aligned addresses
withMutablePtr :: (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> (Ptr ty -> prim a) -> prim a Source #
Create a pointer on the beginning of the mutable array
and call a function f
.
The mutable buffer can be mutated by the f
function
and the change will be reflected in the mutable array
If the mutable array is unpinned, a trampoline buffer
is created and the data is only copied when f
return.