PrimitiveExtras.PrimArray

primitive-extras-0.10.2.1: Extras for the "primitive" library

Safe Haskell | None
Language | Haskell2010

PrimitiveExtras.PrimArray

Synopsis

- primitiveVector :: Prim a => Vector a -> PrimArray a
- oneHot :: Prim a => Int -> Int -> a -> PrimArray a
- generate :: Prim a => Int -> (Int -> IO a) -> IO (PrimArray a)
- replicate :: Prim a => Int -> IO a -> IO (PrimArray a)
- replicateM :: (Monad m, Prim element) => Int -> m element -> m (PrimArray element)
- traverse_ :: (Applicative f, Prim a) => (a -> f b) -> PrimArray a -> f ()
- traverseWithIndexInRange_ :: Prim a => PrimArray a -> Int -> Int -> (Int -> a -> IO ()) -> IO ()
- toElementsUnfoldl :: Prim prim => PrimArray prim -> Unfoldl prim
- toElementsUnfoldlM :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m prim
- toByteArray :: PrimArray a -> ByteArray
- toPrimitiveVector :: Prim a => PrimArray a -> Vector a
- toUnboxedVector :: Prim a => PrimArray a -> Vector a
- cerealGet :: Prim element => Get Int -> Get element -> Get (PrimArray element)
- cerealGetAsInMemory :: Prim element => Get Int -> Get (PrimArray element)
- cerealPut :: Prim element => Putter Int -> Putter element -> Putter (PrimArray element)
- cerealPutAsInMemory :: Prim element => Putter Int -> Putter (PrimArray element)
- indexCountsFold :: (Integral count, Prim count) => Int -> Fold Int (PrimArray count)
- elementsFoldM :: Prim a => Int -> FoldM IO a (PrimArray a)

# Documentation

primitiveVector :: Prim a => Vector a -> PrimArray a #

Construct from a primitive vector. In case the vector is not a slice, it is an O(1) op.

oneHot #

Arguments

:: Prim a |
=> Int | Size
-> Int | Index
-> a |
-> PrimArray a |

generate :: Prim a => Int -> (Int -> IO a) -> IO (PrimArray a) #

replicate :: Prim a => Int -> IO a -> IO (PrimArray a) #

replicateM :: (Monad m, Prim element) => Int -> m element -> m (PrimArray element) #

Please notice that this function is highly untested

traverse_ :: (Applicative f, Prim a) => (a -> f b) -> PrimArray a -> f () #

traverseWithIndexInRange_ :: Prim a => PrimArray a -> Int -> Int -> (Int -> a -> IO ()) -> IO () #

toElementsUnfoldl :: Prim prim => PrimArray prim -> Unfoldl prim #

toElementsUnfoldlM :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m prim #

toByteArray :: PrimArray a -> ByteArray #

toPrimitiveVector :: Prim a => PrimArray a -> Vector a #

toUnboxedVector :: Prim a => PrimArray a -> Vector a #

cerealGet :: Prim element => Get Int -> Get element -> Get (PrimArray element) #

cerealGetAsInMemory :: Prim element => Get Int -> Get (PrimArray element) #

cerealPut :: Prim element => Putter Int -> Putter element -> Putter (PrimArray element) #

cerealPutAsInMemory :: Prim element => Putter Int -> Putter (PrimArray element) #

indexCountsFold #

Arguments

:: (Integral count, Prim count) |
=> Int | Array size
-> Fold Int (PrimArray count) |

Given a size of the array, construct a fold, which produces an array of index counts.

elementsFoldM #

Arguments

:: Prim a |
=> Int | Array size
-> FoldM IO a (PrimArray a) |

Given a size of the array, construct a fold, which produces an array of elements.