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 :: * -> * = UArray ~(Offset ty) ~(CountOf ty) ~(UArrayBackend ty)
- fromForeignPtr :: PrimType ty => (ForeignPtr ty, Int, Int) -> UArray ty
- withPtr :: (PrimMonad prim, PrimType ty) => UArray ty -> (Ptr ty -> prim a) -> prim a
- copyToPtr :: (PrimType ty, PrimMonad prim) => UArray ty -> Ptr ty -> prim ()
- recast :: (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
PrimType ty => IsList (UArray ty) | |
(PrimType ty, Eq ty) => Eq (UArray ty) | |
Data ty => Data (UArray ty) | |
(PrimType ty, Ord ty) => Ord (UArray ty) | |
(PrimType ty, Show ty) => Show (UArray ty) | |
PrimType ty => Monoid (UArray ty) | |
NormalForm (UArray ty) | |
PrimType ty => Fold1able (UArray ty) # | |
PrimType ty => Foldable (UArray ty) # | |
PrimType ty => IndexedCollection (UArray ty) # | |
PrimType ty => InnerFunctor (UArray ty) # | |
PrimType ty => Copy (UArray ty) # | |
PrimType ty => Collection (UArray ty) # | |
PrimType ty => Sequential (UArray ty) # | |
PrimType ty => Zippable (UArray ty) # | |
PrimType ty => Buildable (UArray ty) # | |
PrimType a => Hashable (UArray a) # | |
type Item (UArray ty) | |
type Element (UArray ty) # | |
type Mutable (UArray ty) # | |
type Step (UArray ty) # | |
fromForeignPtr :: PrimType ty => (ForeignPtr ty, Int, Int) -> UArray ty #
:: (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 :: (PrimType a, PrimType b) => UArray a -> UArray b #
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)) #
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)) #
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 #
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.