Safe Haskell | None |
---|---|
Language | Haskell98 |
- class Layout l => Target l a where
- data Buffer l a
- type TargetI l a = (Target l a, Index l ~ Int)
- empty :: TargetI l a => Name l -> Array l a
- singleton :: TargetI l a => Name l -> a -> Array l a
- fromList :: TargetI l a => Name l -> [a] -> Array l a
- fromListInto :: Target l a => l -> [a] -> Maybe (Array l a)
- generateMaybeS :: TargetI l a => Name l -> Int -> (Int -> Maybe a) -> Maybe (Array l a)
- mapMaybeS :: (BulkI lSrc a, TargetI lDst b) => Name lDst -> (a -> Maybe b) -> Array lSrc a -> Maybe (Array lDst b)
- generateEitherS :: TargetI l a => Name l -> Int -> (Int -> Either err a) -> Either err (Array l a)
- mapEitherS :: (BulkI lSrc a, TargetI lDst b) => Name lDst -> (a -> Either err b) -> Array lSrc a -> Either err (Array lDst b)
Documentation
class Layout l => Target l a where Source #
Class of manifest array representations that can be constructed in a random-access manner.
unsafeNewBuffer, unsafeReadBuffer, unsafeWriteBuffer, unsafeGrowBuffer, unsafeSliceBuffer, unsafeFreezeBuffer, unsafeThawBuffer, touchBuffer, bufferLayout
unsafeNewBuffer :: l -> IO (Buffer l a) Source #
Allocate a new mutable buffer for the given layout.
UNSAFE: The integer must be positive, but this is not checked.
unsafeReadBuffer :: Buffer l a -> Int -> IO a Source #
Read an element from the mutable buffer.
UNSAFE: The index bounds are not checked.
unsafeWriteBuffer :: Buffer l a -> Int -> a -> IO () Source #
Write an element into the mutable buffer.
UNSAFE: The index bounds are not checked.
unsafeGrowBuffer :: Buffer l a -> Int -> IO (Buffer l a) Source #
O(n). Copy the contents of a buffer that is larger by the given number of elements.
UNSAFE: The integer must be positive, but this is not checked.
unsafeSliceBuffer :: Int -> Int -> Buffer l a -> IO (Buffer l a) Source #
O(1). Yield a slice of the buffer without copying.
UNSAFE: The given starting position and length must be within the bounds of the of the source buffer, but this is not checked.
unsafeFreezeBuffer :: Buffer l a -> IO (Array l a) Source #
O(1). Freeze a mutable buffer into an immutable Repa array.
UNSAFE: If the buffer is mutated further then the result of reading from the returned array will be non-deterministic.
unsafeThawBuffer :: Array l a -> IO (Buffer l a) Source #
O(1). Thaw an Array into a mutable buffer.
UNSAFE: The Array is no longer safe to use.
touchBuffer :: Buffer l a -> IO () Source #
Ensure the array is still live at this point. Sometimes needed when the mutable buffer is a ForeignPtr with a finalizer.
bufferLayout :: Buffer l a -> l Source #
O(1). Get the layout from a Buffer.
Target B a Source # | Boxed buffers. |
Storable a => Target F a Source # | Foreign buffers |
Unbox a => Target U a Source # | Unboxed buffers. |
(Bulk l a, Target l a, (~) * (Index l) Int) => Target N (Array l a) Source # | |
(Layout l, (~) * (Index r) Int, Target r a) => Target (E r l) a Source # | Dense buffers. |
(Target l1 a, Target l2 b, (~) * (Index l1) (Index l2)) => Target (T2 l1 l2) (a, b) Source # | Tupled buffers. |
type TargetI l a = (Target l a, Index l ~ Int) Source #
Constraint synonym that requires an integer index space.
singleton :: TargetI l a => Name l -> a -> Array l a Source #
O(1). Create a new empty array containing a single element.
fromList :: TargetI l a => Name l -> [a] -> Array l a Source #
O(length src). Construct a linear array from a list of elements.
mapMaybeS :: (BulkI lSrc a, TargetI lDst b) => Name lDst -> (a -> Maybe b) -> Array lSrc a -> Maybe (Array lDst b) Source #