Copyright | (c) Edward Kmett 2015 |
---|---|
License | BSD-style |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Portability | non-portable |
Safe Haskell | Unsafe |
Language | Haskell2010 |
Various sorts of primitive arrays
- sizeofArray :: Array a -> Int
- sizeofMutableArray :: MutableArray s a -> Int
- casArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> a -> a -> m (Int, a)
- atomicModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- atomicModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- modifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- modifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- fetchModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- fetchModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localAtomicModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- localAtomicModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- localModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localFetchModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localFetchModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- sizeOfByteArray :: ByteArray -> Int
- sizeOfMutableByteArray :: MutableByteArray s -> Int
- casIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> Int -> m Int
- atomicReadIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m Int
- atomicWriteIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m ()
- fetchAddIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int
- fetchSubIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int
- fetchAndIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int
- fetchNandIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int
- fetchOrIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int
- fetchXorIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int
- prefetchByteArray0 :: PrimMonad m => ByteArray -> Int -> m ()
- prefetchByteArray1 :: PrimMonad m => ByteArray -> Int -> m ()
- prefetchByteArray2 :: PrimMonad m => ByteArray -> Int -> m ()
- prefetchByteArray3 :: PrimMonad m => ByteArray -> Int -> m ()
- prefetchMutableByteArray0 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m ()
- prefetchMutableByteArray1 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m ()
- prefetchMutableByteArray2 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m ()
- prefetchMutableByteArray3 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m ()
- prefetchValue0 :: PrimMonad m => a -> m ()
- prefetchValue1 :: PrimMonad m => a -> m ()
- prefetchValue2 :: PrimMonad m => a -> m ()
- prefetchValue3 :: PrimMonad m => a -> m ()
- data SmallArray a = SmallArray (SmallArray# a)
- data SmallMutableArray s a = SmallMutableArray (SmallMutableArray# s a)
- newSmallArray :: PrimMonad m => Int -> a -> m (SmallMutableArray (PrimState m) a)
- readSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> m a
- writeSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> a -> m ()
- indexSmallArray :: SmallArray a -> Int -> a
- indexSmallArrayM :: Monad m => SmallArray a -> Int -> m a
- unsafeFreezeSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> m (SmallArray a)
- unsafeThawSmallArray :: PrimMonad m => SmallArray a -> m (SmallMutableArray (PrimState m) a)
- sameSmallMutableArray :: SmallMutableArray s a -> SmallMutableArray s a -> Bool
- copySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> SmallArray a -> Int -> Int -> m ()
- copySmallMutableArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> SmallMutableArray (PrimState m) a -> Int -> Int -> m ()
- cloneSmallArray :: SmallArray a -> Int -> Int -> SmallArray a
- cloneSmallMutableArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> Int -> m (SmallMutableArray (PrimState m) a)
- casSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> a -> a -> m (Int, a)
- sizeOfSmallArray :: SmallArray a -> Int
- sizeOfSmallMutableArray :: SmallMutableArray s a -> Int
- atomicModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- atomicModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- modifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- modifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- fetchModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- fetchModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localAtomicModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- localAtomicModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b
- localModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localFetchModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- localFetchModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a
- data ArrayArray = ArrayArray ArrayArray#
- unsafeFreezeArrayArray :: MonadPrim s m => MutableArrayArray s -> m ArrayArray
- unsafeThawArrayArray :: MonadPrim s m => ArrayArray -> m (MutableArrayArray s)
- sizeofArrayArray :: ArrayArray -> Int
- indexArrayArray :: ArrayArray -> Int -> Array a
- indexArrayArrayArray :: ArrayArray -> Int -> ArrayArray
- indexByteArrayArray :: ArrayArray -> Int -> ByteArray
- indexMutableArrayArray :: ArrayArray -> Int -> MutableArray s a
- indexMutableArrayArrayArray :: ArrayArray -> Int -> MutableArrayArray s
- indexMutableByteArrayArray :: ArrayArray -> Int -> MutableByteArray s
- indexSmallArrayArray :: ArrayArray -> Int -> SmallArray a
- indexSmallMutableArrayArray :: ArrayArray -> Int -> SmallMutableArray s a
- indexSmallArrayArrayArray :: ArrayArray -> Int -> SmallArrayArray
- indexSmallMutableArrayArrayArray :: ArrayArray -> Int -> SmallMutableArrayArray s
- data MutableArrayArray s = MutableArrayArray (MutableArrayArray# s)
- newArrayArray :: MonadPrim s m => Int -> m (MutableArrayArray s)
- copyArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> ArrayArray -> Int -> Int -> m ()
- copyMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableArrayArray s -> Int -> Int -> m ()
- cloneArrayArray :: ArrayArray -> Int -> Int -> ArrayArray
- cloneMutableArrayArray :: PrimMonad m => MutableArrayArray (PrimState m) -> Int -> Int -> m (MutableArrayArray (PrimState m))
- sizeofMutableArrayArray :: MutableArrayArray s -> Int
- readArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (Array a)
- readArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m ArrayArray
- readByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m ByteArray
- readMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (MutableArray s a)
- readMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (MutableArrayArray s)
- readMutableByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (MutableByteArray s)
- readSmallArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (SmallArray a)
- readSmallMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (SmallMutableArray s a)
- readSmallArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m SmallArrayArray
- readSmallMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (SmallMutableArrayArray s)
- writeArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> Array a -> m ()
- writeArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> ArrayArray -> m ()
- writeByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> ByteArray -> m ()
- writeMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableArray s a -> m ()
- writeMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableArrayArray s -> m ()
- writeMutableByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableByteArray s -> m ()
- writeSmallArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallArray a -> m ()
- writeSmallMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallMutableArray s a -> m ()
- writeSmallArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallArrayArray -> m ()
- writeSmallMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallMutableArrayArray s -> m ()
- data SmallArrayArray = SmallArrayArray (SmallArray# Any)
- unsafeFreezeSmallArrayArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> m SmallArrayArray
- unsafeThawSmallArrayArray :: PrimMonad m => SmallArrayArray -> m (SmallMutableArrayArray (PrimState m))
- sizeofSmallArrayArray :: SmallArrayArray -> Int
- indexArraySmallArray :: SmallArrayArray -> Int -> Array a
- indexArrayArraySmallArray :: SmallArrayArray -> Int -> ArrayArray
- indexByteArraySmallArray :: SmallArrayArray -> Int -> ByteArray
- indexMutableArraySmallArray :: SmallArrayArray -> Int -> MutableArray s a
- indexMutableArrayArraySmallArray :: SmallArrayArray -> Int -> MutableArrayArray s
- indexMutableByteArraySmallArray :: SmallArrayArray -> Int -> MutableByteArray s
- indexSmallArraySmallArray :: SmallArrayArray -> Int -> SmallArray a
- indexSmallMutableArraySmallArray :: SmallArrayArray -> Int -> SmallMutableArray s a
- indexSmallArrayArraySmallArray :: SmallArrayArray -> Int -> SmallArrayArray
- indexSmallMutableArrayArraySmallArray :: SmallArrayArray -> Int -> SmallMutableArrayArray s
- data SmallMutableArrayArray s = SmallMutableArrayArray (SmallMutableArray# s Any)
- newSmallArrayArray :: PrimMonad m => Int -> m (SmallMutableArrayArray (PrimState m))
- copySmallArrayArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallArrayArray -> Int -> Int -> m ()
- copySmallMutableArrayArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallMutableArrayArray (PrimState m) -> Int -> Int -> m ()
- cloneSmallArrayArray :: SmallArrayArray -> Int -> Int -> SmallArrayArray
- cloneSmallMutableArrayArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> Int -> m (SmallMutableArrayArray (PrimState m))
- sizeofSmallMutableArrayArray :: SmallMutableArrayArray s -> Int
- readArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (Array a)
- readArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m ArrayArray
- readByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m ByteArray
- readMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (MutableArray s a)
- readMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (MutableArrayArray s)
- readMutableByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (MutableByteArray s)
- readSmallArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (SmallArray a)
- readSmallMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (SmallMutableArray s a)
- readSmallArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m SmallArrayArray
- readSmallMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (SmallMutableArrayArray s)
- writeArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> Array a -> m ()
- writeArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> ArrayArray -> m ()
- writeByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> ByteArray -> m ()
- writeMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> MutableArray s a -> m ()
- writeMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> MutableArrayArray s -> m ()
- writeMutableByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> MutableByteArray s -> m ()
- writeSmallArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallArray a -> m ()
- writeSmallMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallMutableArray s a -> m ()
- writeSmallArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallArrayArray -> m ()
- writeSmallMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallMutableArrayArray s -> m ()
Array Primitives
sizeofArray :: Array a -> Int Source
sizeofMutableArray :: MutableArray s a -> Int Source
atomicModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
atomicModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
modifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the new result
modifyArray
m i f =atomicModifyArray
m i $ a -> let b = f a in (b, b)
modifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the new result.
Can this be smarter? e.g. start it off already as a blackhole we appear to be evaluating, putting frames on the stack, etc. That would avoid anybody ever getting and seeing the unevaluated closure.
fetchModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the old result.
fetchModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the old result.
Capability-local array manipulation primitives
localAtomicModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
Modify the contents of a position in an array in a manner that at least can't be preempted another thread in the current capability.
localAtomicModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
Modify the contents of a position in an array strictly in a manner that at least can't be preempted another thread in the current capability.
localModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the new result.
Logically,
localModifyArray
m i f =localAtomicModifyArray
m i $ a -> let b = f a in (b, b)
but it is a bit more efficient.
localModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the new result.
Can this be smarter? e.g. start it off already as a blackhole we appear to be evaluating, putting frames on the stack, etc. That would avoid anybody ever getting and seeing the unevaluated closure.
localFetchModifyArray :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the old result.
localFetchModifyArray' :: PrimMonad m => MutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the old result.
ByteArray Primitives
sizeOfByteArray :: ByteArray -> Int Source
sizeOfMutableByteArray :: MutableByteArray s -> Int Source
atomicReadIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m Int Source
atomicWriteIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m () Source
fetchAddIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int Source
fetchSubIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int Source
fetchAndIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int Source
fetchNandIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int Source
fetchOrIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int Source
fetchXorIntArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Int -> m Int Source
Prefetching
prefetchByteArray0 :: PrimMonad m => ByteArray -> Int -> m () Source
prefetchByteArray1 :: PrimMonad m => ByteArray -> Int -> m () Source
prefetchByteArray2 :: PrimMonad m => ByteArray -> Int -> m () Source
prefetchByteArray3 :: PrimMonad m => ByteArray -> Int -> m () Source
prefetchMutableByteArray0 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m () Source
prefetchMutableByteArray1 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m () Source
prefetchMutableByteArray2 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m () Source
prefetchMutableByteArray3 :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> m () Source
prefetchValue0 :: PrimMonad m => a -> m () Source
prefetchValue1 :: PrimMonad m => a -> m () Source
prefetchValue2 :: PrimMonad m => a -> m () Source
prefetchValue3 :: PrimMonad m => a -> m () Source
SmallArrays
data SmallArray a Source
Boxed arrays
Monad SmallArray Source | |
Functor SmallArray Source | |
Applicative SmallArray Source | |
Foldable SmallArray Source | |
Traversable SmallArray Source | |
MonadZip SmallArray Source | |
Alternative SmallArray Source | |
MonadPlus SmallArray Source | |
IsList (SmallArray a) Source | |
Eq a => Eq (SmallArray a) Source | |
Data a => Data (SmallArray a) Source | |
Ord a => Ord (SmallArray a) Source | |
Read a => Read (SmallArray a) Source | |
Show a => Show (SmallArray a) Source | |
Monoid (SmallArray a) Source | |
NFData a => NFData (SmallArray a) Source | |
type Item (SmallArray a) = a Source |
data SmallMutableArray s a Source
Mutable boxed arrays associated with a primitive state token.
Eq (SmallMutableArray s a) Source |
newSmallArray :: PrimMonad m => Int -> a -> m (SmallMutableArray (PrimState m) a) Source
Create a new mutable array of the specified size and initialise all elements with the given value.
readSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> m a Source
Read a value from the array at the given index.
writeSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> a -> m () Source
Write a value to the array at the given index.
indexSmallArray :: SmallArray a -> Int -> a Source
Read a value from the immutable array at the given index.
indexSmallArrayM :: Monad m => SmallArray a -> Int -> m a Source
Monadically read a value from the immutable array at the given index. This allows us to be strict in the array while remaining lazy in the read element which is very useful for collective operations. Suppose we want to copy an array. We could do something like this:
copy marr arr ... = do ... writeSmallArray marr i (indexSmallArray arr i) ... ...
But since primitive arrays are lazy, the calls to indexSmallArray
will not be
evaluated. Rather, marr
will be filled with thunks each of which would
retain a reference to arr
. This is definitely not what we want!
With indexSmallArrayM
, we can instead write
copy marr arr ... = do ... x <- indexSmallArrayM arr i writeSmallArray marr i x ...
Now, indexing is executed immediately although the returned element is still not evaluated.
unsafeFreezeSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> m (SmallArray a) Source
Convert a mutable array to an immutable one without copying. The array should not be modified after the conversion.
unsafeThawSmallArray :: PrimMonad m => SmallArray a -> m (SmallMutableArray (PrimState m) a) Source
Convert an immutable array to an mutable one without copying. The immutable array should not be used after the conversion.
sameSmallMutableArray :: SmallMutableArray s a -> SmallMutableArray s a -> Bool Source
Check whether the two arrays refer to the same memory block.
:: PrimMonad m | |
=> SmallMutableArray (PrimState m) a | destination array |
-> Int | offset into destination array |
-> SmallArray a | source array |
-> Int | offset into source array |
-> Int | number of elements to copy |
-> m () |
Copy a slice of an immutable array to a mutable array.
:: PrimMonad m | |
=> SmallMutableArray (PrimState m) a | destination array |
-> Int | offset into destination array |
-> SmallMutableArray (PrimState m) a | source array |
-> Int | offset into source array |
-> Int | number of elements to copy |
-> m () |
Copy a slice of a mutable array to another array. The two arrays may not be the same.
:: SmallArray a | source array |
-> Int | offset into destination array |
-> Int | number of elements to copy |
-> SmallArray a |
Return a newly allocated SmallArray with the specified subrange of the provided SmallArray. The provided SmallArray should contain the full subrange specified by the two Ints, but this is not checked.
:: PrimMonad m | |
=> SmallMutableArray (PrimState m) a | source array |
-> Int | offset into destination array |
-> Int | number of elements to copy |
-> m (SmallMutableArray (PrimState m) a) |
Return a newly allocated SmallMutableArray. with the specified subrange of the provided SmallMutableArray. The provided SmallMutableArray should contain the full subrange specified by the two Ints, but this is not checked.
casSmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> a -> a -> m (Int, a) Source
Perform an unsafe, machine-level atomic compare and swap on an element within an array.
sizeOfSmallArray :: SmallArray a -> Int Source
sizeOfSmallMutableArray :: SmallMutableArray s a -> Int Source
Atomic modification
atomicModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
atomicModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
modifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the new result
modifySmallArray
m i f =atomicModifySmallArray
m i $ a -> let b = f a in (b, b)
modifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the new result.
Can this be smarter? e.g. start it off already as a blackhole we appear to be evaluating, putting frames on the stack, etc. That would avoid anybody ever getting and seeing the unevaluated closure.
fetchModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the old result.
fetchModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the old result.
localAtomicModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
Modify the contents of a position in an array in a manner that at least can't be preempted another thread in the current capability.
localAtomicModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> (a, b)) -> m b Source
Modify the contents of a position in an array strictly in a manner that at least can't be preempted another thread in the current capability.
localModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the new result.
Logically,
localModifySmallArray
m i f =localAtomicModifySmallArray
m i $ a -> let b = f a in (b, b)
but it is a bit more efficient.
localModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the new result.
Can this be smarter? e.g. start it off already as a blackhole we appear to be evaluating, putting frames on the stack, etc. That would avoid anybody ever getting and seeing the unevaluated closure.
localFetchModifySmallArray :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position. Return the old result.
localFetchModifySmallArray' :: PrimMonad m => SmallMutableArray (PrimState m) a -> Int -> (a -> a) -> m a Source
Modify the contents of an array at a given position strictly. Return the old result.
ArrayArrays
unsafeFreezeArrayArray :: MonadPrim s m => MutableArrayArray s -> m ArrayArray Source
unsafeThawArrayArray :: MonadPrim s m => ArrayArray -> m (MutableArrayArray s) Source
sizeofArrayArray :: ArrayArray -> Int Source
Indexing
indexArrayArray :: ArrayArray -> Int -> Array a Source
indexArrayArrayArray :: ArrayArray -> Int -> ArrayArray Source
indexByteArrayArray :: ArrayArray -> Int -> ByteArray Source
indexMutableArrayArray :: ArrayArray -> Int -> MutableArray s a Source
indexMutableByteArrayArray :: ArrayArray -> Int -> MutableByteArray s Source
indexSmallArrayArray :: ArrayArray -> Int -> SmallArray a Source
indexSmallMutableArrayArray :: ArrayArray -> Int -> SmallMutableArray s a Source
MutableArrayArrays
data MutableArrayArray s Source
newArrayArray :: MonadPrim s m => Int -> m (MutableArrayArray s) Source
copyArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> ArrayArray -> Int -> Int -> m () Source
copyMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableArrayArray s -> Int -> Int -> m () Source
:: ArrayArray | source array |
-> Int | offset into destination array |
-> Int | number of elements to copy |
-> ArrayArray |
Return a newly allocated ArrayArray with the specified subrange of the provided ArrayArray. The provided ArrayArray should contain the full subrange specified by the two Ints, but this is not checked.
:: PrimMonad m | |
=> MutableArrayArray (PrimState m) | source array |
-> Int | offset into destination array |
-> Int | number of elements to copy |
-> m (MutableArrayArray (PrimState m)) |
Return a newly allocated MutableArrayArray. with the specified subrange of the provided MutableArrayArray. The provided MutableArrayArray should contain the full subrange specified by the two Ints, but this is not checked.
Reading
readArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (Array a) Source
readArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m ArrayArray Source
readByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m ByteArray Source
readMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (MutableArray s a) Source
readMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (MutableArrayArray s) Source
readMutableByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (MutableByteArray s) Source
readSmallArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (SmallArray a) Source
readSmallMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (SmallMutableArray s a) Source
readSmallArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m SmallArrayArray Source
readSmallMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> m (SmallMutableArrayArray s) Source
Writing
writeArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> Array a -> m () Source
writeArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> ArrayArray -> m () Source
writeByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> ByteArray -> m () Source
writeMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableArray s a -> m () Source
writeMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableArrayArray s -> m () Source
writeMutableByteArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> MutableByteArray s -> m () Source
writeSmallArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallArray a -> m () Source
writeSmallMutableArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallMutableArray s a -> m () Source
writeSmallArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallArrayArray -> m () Source
writeSmallMutableArrayArrayArray :: MonadPrim s m => MutableArrayArray s -> Int -> SmallMutableArrayArray s -> m () Source
SmallArrayArrays
unsafeFreezeSmallArrayArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> m SmallArrayArray Source
unsafeThawSmallArrayArray :: PrimMonad m => SmallArrayArray -> m (SmallMutableArrayArray (PrimState m)) Source
Indexing
indexArraySmallArray :: SmallArrayArray -> Int -> Array a Source
indexByteArraySmallArray :: SmallArrayArray -> Int -> ByteArray Source
indexMutableArraySmallArray :: SmallArrayArray -> Int -> MutableArray s a Source
indexMutableByteArraySmallArray :: SmallArrayArray -> Int -> MutableByteArray s Source
indexSmallArraySmallArray :: SmallArrayArray -> Int -> SmallArray a Source
SmallMutableMutableArrayArrays
data SmallMutableArrayArray s Source
newSmallArrayArray :: PrimMonad m => Int -> m (SmallMutableArrayArray (PrimState m)) Source
:: PrimMonad m | |
=> SmallMutableArrayArray (PrimState m) | destination array |
-> Int | offset into destination array |
-> SmallArrayArray | source array |
-> Int | offset into source array |
-> Int | number of elements to copy |
-> m () |
Copy a slice of an immutable array to a mutable array.
copySmallMutableArrayArray Source
:: PrimMonad m | |
=> SmallMutableArrayArray (PrimState m) | destination array |
-> Int | offset into destination array |
-> SmallMutableArrayArray (PrimState m) | source array |
-> Int | offset into source array |
-> Int | number of elements to copy |
-> m () |
Copy a slice of a mutable array to another array. The two arrays may not be the same.
:: SmallArrayArray | source array |
-> Int | offset into destination array |
-> Int | number of elements to copy |
-> SmallArrayArray |
Return a newly allocated SmallArray with the specified subrange of the provided SmallArray. The provided SmallArray should contain the full subrange specified by the two Ints, but this is not checked.
cloneSmallMutableArrayArray Source
:: PrimMonad m | |
=> SmallMutableArrayArray (PrimState m) | source array |
-> Int | offset into destination array |
-> Int | number of elements to copy |
-> m (SmallMutableArrayArray (PrimState m)) |
Return a newly allocated SmallMutableArray. with the specified subrange of the provided SmallMutableArray. The provided SmallMutableArray should contain the full subrange specified by the two Ints, but this is not checked.
Reading
readArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (Array a) Source
readArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m ArrayArray Source
readByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m ByteArray Source
readMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (MutableArray s a) Source
readMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (MutableArrayArray s) Source
readMutableByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (MutableByteArray s) Source
readSmallArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (SmallArray a) Source
readSmallMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (SmallMutableArray s a) Source
readSmallArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m SmallArrayArray Source
readSmallMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> m (SmallMutableArrayArray s) Source
Writing
writeArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> Array a -> m () Source
writeArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> ArrayArray -> m () Source
writeByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> ByteArray -> m () Source
writeMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> MutableArray s a -> m () Source
writeMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> MutableArrayArray s -> m () Source
writeMutableByteArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> MutableByteArray s -> m () Source
writeSmallArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallArray a -> m () Source
writeSmallMutableArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallMutableArray s a -> m () Source
writeSmallArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallArrayArray -> m () Source
writeSmallMutableArrayArraySmallArray :: PrimMonad m => SmallMutableArrayArray (PrimState m) -> Int -> SmallMutableArrayArray s -> m () Source