basement-0.0.4: Foundation scrap box of array & string

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Basement.UArray

Contents

- methods
- internal methods
- Creation
- accessors
- Functions

Description

An unboxed array of primitive types

All the cells in the array are in one chunk of contiguous memory.

Synopsis

- data UArray ty = UArray !(Offset ty) !(CountOf ty) !(UArrayBackend ty)
- class Eq ty => PrimType ty where
- copy :: PrimType ty => UArray ty -> UArray ty
- unsafeCopyAtRO :: forall prim ty. (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> Offset ty -> UArray ty -> Offset ty -> CountOf ty -> prim ()
- recast :: forall a b. (PrimType a, PrimType b) => UArray a -> UArray b
- unsafeRecast :: (PrimType a, PrimType b) => UArray a -> UArray b
- length :: UArray ty -> CountOf ty
- freeze :: (PrimType ty, PrimMonad prim) => MUArray ty (PrimState prim) -> prim (UArray ty)
- unsafeFreeze :: PrimMonad prim => MUArray ty (PrimState prim) -> prim (UArray ty)
- thaw :: (PrimMonad prim, PrimType ty) => UArray ty -> prim (MUArray ty (PrimState prim))
- unsafeThaw :: (PrimType ty, PrimMonad prim) => UArray ty -> prim (MUArray ty (PrimState prim))
- vFromListN :: forall ty. PrimType ty => CountOf ty -> [ty] -> UArray ty
- new :: (PrimMonad prim, PrimType ty) => CountOf ty -> prim (MUArray ty (PrimState prim))
- create :: forall ty. PrimType ty => CountOf ty -> (Offset ty -> ty) -> UArray ty
- createFromIO :: PrimType ty => CountOf ty -> (Ptr ty -> IO (CountOf ty)) -> IO (UArray ty)
- createFromPtr :: PrimType ty => Ptr ty -> CountOf ty -> IO (UArray ty)
- sub :: PrimType ty => UArray ty -> Offset ty -> Offset ty -> UArray ty
- copyToPtr :: forall ty prim. (PrimType ty, PrimMonad prim) => UArray ty -> Ptr ty -> prim ()
- withPtr :: forall ty prim a. (PrimMonad prim, PrimType ty) => UArray ty -> (Ptr ty -> prim a) -> prim a
- withMutablePtr :: (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> (Ptr ty -> prim a) -> prim a
- unsafeFreezeShrink :: (PrimType ty, PrimMonad prim) => MUArray ty (PrimState prim) -> CountOf ty -> prim (UArray ty)
- freezeShrink :: (PrimType ty, PrimMonad prim) => MUArray ty (PrimState prim) -> CountOf ty -> prim (UArray ty)
- fromBlock :: PrimType ty => Block ty -> UArray ty
- toBlock :: PrimType ty => UArray ty -> Block ty
- update :: PrimType ty => UArray ty -> [(Offset ty, ty)] -> UArray ty
- unsafeUpdate :: PrimType ty => UArray ty -> [(Offset ty, ty)] -> UArray ty
- unsafeIndex :: forall ty. PrimType ty => UArray ty -> Offset ty -> ty
- unsafeIndexer :: (PrimMonad prim, PrimType ty) => UArray ty -> ((Offset ty -> ty) -> prim a) -> prim a
- unsafeDewrap :: (ByteArray# -> Offset ty -> a) -> (Ptr ty -> Offset ty -> ST s a) -> UArray ty -> a
- unsafeRead :: (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> Offset ty -> prim ty
- unsafeWrite :: (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> Offset ty -> ty -> prim ()
- equalMemcmp :: PrimType ty => UArray ty -> UArray ty -> Bool
- singleton :: PrimType ty => ty -> UArray ty
- replicate :: PrimType ty => CountOf ty -> ty -> UArray ty
- map :: (PrimType a, PrimType b) => (a -> b) -> UArray a -> UArray b
- mapIndex :: (PrimType a, PrimType b) => (Offset b -> a -> b) -> UArray a -> UArray b
- findIndex :: PrimType ty => ty -> UArray ty -> Maybe (Offset ty)
- revFindIndex :: PrimType ty => ty -> UArray ty -> Maybe (Offset ty)
- index :: PrimType ty => UArray ty -> Offset ty -> ty
- null :: UArray ty -> Bool
- take :: CountOf ty -> UArray ty -> UArray ty
- unsafeTake :: CountOf ty -> UArray ty -> UArray ty
- drop :: CountOf ty -> UArray ty -> UArray ty
- unsafeDrop :: CountOf ty -> UArray ty -> UArray ty
- splitAt :: CountOf ty -> UArray ty -> (UArray ty, UArray ty)
- revDrop :: CountOf ty -> UArray ty -> UArray ty
- revTake :: CountOf ty -> UArray ty -> UArray ty
- revSplitAt :: CountOf ty -> UArray ty -> (UArray ty, UArray ty)
- splitOn :: PrimType ty => (ty -> Bool) -> UArray ty -> [UArray ty]
- break :: forall ty. PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty)
- breakEnd :: forall ty. PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty)
- breakElem :: PrimType ty => ty -> UArray ty -> (UArray ty, UArray ty)
- breakLine :: UArray Word8 -> Either Bool (UArray Word8, UArray Word8)
- elem :: PrimType ty => ty -> UArray ty -> Bool
- indices :: PrimType ty => UArray ty -> UArray ty -> [Offset ty]
- intersperse :: forall ty. PrimType ty => ty -> UArray ty -> UArray ty
- span :: PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty)
- spanEnd :: PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty)
- cons :: PrimType ty => ty -> UArray ty -> UArray ty
- snoc :: PrimType ty => UArray ty -> ty -> UArray ty
- uncons :: PrimType ty => UArray ty -> Maybe (ty, UArray ty)
- unsnoc :: PrimType ty => UArray ty -> Maybe (UArray ty, ty)
- find :: PrimType ty => (ty -> Bool) -> UArray ty -> Maybe ty
- sortBy :: forall ty. PrimType ty => (ty -> ty -> Ordering) -> UArray ty -> UArray ty
- filter :: forall ty. PrimType ty => (ty -> Bool) -> UArray ty -> UArray ty
- reverse :: forall ty. PrimType ty => UArray ty -> UArray ty
- replace :: PrimType ty => UArray ty -> UArray ty -> UArray ty -> UArray ty
- foldr :: PrimType ty => (ty -> a -> a) -> a -> UArray ty -> a
- foldl' :: PrimType ty => (a -> ty -> a) -> a -> UArray ty -> a
- foldr1 :: PrimType ty => (ty -> ty -> ty) -> NonEmpty (UArray ty) -> ty
- foldl1' :: PrimType ty => (ty -> ty -> ty) -> NonEmpty (UArray ty) -> ty
- all :: PrimType ty => (ty -> Bool) -> UArray ty -> Bool
- any :: PrimType ty => (ty -> Bool) -> UArray ty -> Bool
- isPrefixOf :: PrimType ty => UArray ty -> UArray ty -> Bool
- isSuffixOf :: PrimType ty => UArray ty -> UArray ty -> Bool
- foreignMem :: PrimType ty => FinalPtr ty -> CountOf ty -> UArray ty
- fromForeignPtr :: PrimType ty => (ForeignPtr ty, Int, Int) -> UArray ty
- builderAppend :: (PrimType ty, PrimMonad state) => ty -> Builder (UArray ty) (MUArray ty) ty state err ()
- builderBuild :: (PrimType ty, PrimMonad m) => Int -> Builder (UArray ty) (MUArray ty) ty m err () -> m (Either err (UArray ty))
- builderBuild_ :: (PrimType ty, PrimMonad m) => Int -> Builder (UArray ty) (MUArray ty) ty m () () -> m (UArray ty)
- toHexadecimal :: PrimType ty => UArray ty -> UArray Word8
- toBase64Internal :: PrimType ty => Addr# -> UArray ty -> Bool -> UArray Word8

# Documentation

data UArray ty Source #

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

Constructors

UArray !(Offset ty) !(CountOf ty) !(UArrayBackend ty) |

Instances

From AsciiString (UArray Word8) Source # |
Methods from :: AsciiString -> UArray Word8 Source #
From String (UArray Word8) Source # |
Methods from :: String -> UArray Word8 Source #
PrimType ty => IsList (UArray ty) Source # |
Associated Types type Item (UArray ty) :: * # Methods fromList :: [Item (UArray ty)] -> UArray ty # fromListN :: Int -> [Item (UArray ty)] -> UArray ty # toList :: UArray ty -> [Item (UArray ty)] #
(PrimType ty, Eq ty) => Eq (UArray ty) Source # |
Methods (==) :: UArray ty -> UArray ty -> Bool # (/=) :: UArray ty -> UArray ty -> Bool #
Data ty => Data (UArray ty) Source # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UArray ty -> c (UArray ty) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (UArray ty) #

toConstr :: UArray ty -> Constr #

dataTypeOf :: UArray ty -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (UArray ty)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UArray ty)) #

gmapT :: (forall b. Data b => b -> b) -> UArray ty -> UArray ty #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UArray ty -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UArray ty -> r #

gmapQ :: (forall d. Data d => d -> u) -> UArray ty -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> UArray ty -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> UArray ty -> m (UArray ty) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UArray ty -> m (UArray ty) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UArray ty -> m (UArray ty) #

(PrimType ty, Ord ty) => Ord (UArray ty) Source # |
Methods compare :: UArray ty -> UArray ty -> Ordering # (<) :: UArray ty -> UArray ty -> Bool # (<=) :: UArray ty -> UArray ty -> Bool # (>) :: UArray ty -> UArray ty -> Bool # (>=) :: UArray ty -> UArray ty -> Bool # max :: UArray ty -> UArray ty -> UArray ty # min :: UArray ty -> UArray ty -> UArray ty #
(PrimType ty, Show ty) => Show (UArray ty) Source # |
Methods showsPrec :: Int -> UArray ty -> ShowS # show :: UArray ty -> String # showList :: [UArray ty] -> ShowS #
PrimType ty => Semigroup (UArray ty) Source # |
Methods (<>) :: UArray ty -> UArray ty -> UArray ty # sconcat :: NonEmpty (UArray ty) -> UArray ty # stimes :: Integral b => b -> UArray ty -> UArray ty #
PrimType ty => Monoid (UArray ty) Source # |
Methods mempty :: UArray ty # mappend :: UArray ty -> UArray ty -> UArray ty # mconcat :: [UArray ty] -> UArray ty #
NormalForm (UArray ty) Source # |
Methods toNormalForm :: UArray ty -> () Source #
TryFrom (UArray Word8) String Source # |
Methods tryFrom :: UArray Word8 -> Maybe String Source #
PrimType ty => From (Block ty) (UArray ty) Source # |
Methods from :: Block ty -> UArray ty Source #
PrimType ty => From (UArray ty) (Array ty) Source # |
Methods from :: UArray ty -> Array ty Source #
PrimType ty => From (UArray ty) (Block ty) Source # |
Methods from :: UArray ty -> Block ty Source #
PrimType ty => From (Array ty) (UArray ty) Source # |
Methods from :: Array ty -> UArray ty Source #
(NatWithinBound (CountOf ty) n, KnownNat n, PrimType ty) => TryFrom (UArray ty) (BlockN n ty) Source # |
Methods tryFrom :: UArray ty -> Maybe (BlockN n ty) Source #
(NatWithinBound Int n, PrimType ty) => From (BlockN n ty) (UArray ty) Source # |
Methods from :: BlockN n ty -> UArray ty Source #
type Item (UArray ty) Source # |
type Item (UArray ty) = ty

class Eq ty => PrimType ty where Source #

Represent the accessor for types that can be stored in the UArray and MUArray.

Types need to be a instance of storable and have fixed sized.

Minimal complete definition

primSizeInBytes, primShiftToBytes, primBaUIndex, primMbaURead, primMbaUWrite, primAddrIndex, primAddrRead, primAddrWrite

Methods

primSizeInBytes :: Proxy ty -> CountOf Word8 Source #

get the size in bytes of a ty element

primShiftToBytes :: Proxy ty -> Int Source #

get the shift size

primBaUIndex :: ByteArray# -> Offset ty -> ty Source #

return the element stored at a specific index

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset ty -> prim ty Source #

Read an element at an index in a mutable array

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim () Source #

Write an element to a specific cell in a mutable array.

primAddrIndex :: Addr# -> Offset ty -> ty Source #

Read from Address, without a state. the value read should be considered a constant for all pratical purpose, otherwise bad thing will happens.

primAddrRead :: PrimMonad prim => Addr# -> Offset ty -> prim ty Source #

Read a value from Addr in a specific primitive monad

primAddrWrite :: PrimMonad prim => Addr# -> Offset ty -> ty -> prim () Source #

Write a value to Addr in a specific primitive monad

Instances

PrimType Char Source # |

Methods

primSizeInBytes :: Proxy * Char -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Char -> Int Source #

primBaUIndex :: ByteArray# -> Offset Char -> Char Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char -> prim Char Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char -> Char -> prim () Source #

primAddrIndex :: Addr# -> Offset Char -> Char Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Char -> prim Char Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Char -> Char -> prim () Source #

PrimType Double Source # |

Methods

primSizeInBytes :: Proxy * Double -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Double -> Int Source #

primBaUIndex :: ByteArray# -> Offset Double -> Double Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Double -> prim Double Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Double -> Double -> prim () Source #

primAddrIndex :: Addr# -> Offset Double -> Double Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Double -> prim Double Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Double -> Double -> prim () Source #

PrimType Float Source # |

Methods

primSizeInBytes :: Proxy * Float -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Float -> Int Source #

primBaUIndex :: ByteArray# -> Offset Float -> Float Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Float -> prim Float Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Float -> Float -> prim () Source #

primAddrIndex :: Addr# -> Offset Float -> Float Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Float -> prim Float Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Float -> Float -> prim () Source #

PrimType Int Source # |

Methods

primSizeInBytes :: Proxy * Int -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Int -> Int Source #

primBaUIndex :: ByteArray# -> Offset Int -> Int Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int -> prim Int Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int -> Int -> prim () Source #

primAddrIndex :: Addr# -> Offset Int -> Int Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Int -> prim Int Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Int -> Int -> prim () Source #

PrimType Int8 Source # |

Methods

primSizeInBytes :: Proxy * Int8 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Int8 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Int8 -> Int8 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int8 -> prim Int8 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int8 -> Int8 -> prim () Source #

primAddrIndex :: Addr# -> Offset Int8 -> Int8 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Int8 -> prim Int8 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Int8 -> Int8 -> prim () Source #

PrimType Int16 Source # |

Methods

primSizeInBytes :: Proxy * Int16 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Int16 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Int16 -> Int16 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int16 -> prim Int16 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int16 -> Int16 -> prim () Source #

primAddrIndex :: Addr# -> Offset Int16 -> Int16 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Int16 -> prim Int16 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Int16 -> Int16 -> prim () Source #

PrimType Int32 Source # |

Methods

primSizeInBytes :: Proxy * Int32 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Int32 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Int32 -> Int32 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int32 -> prim Int32 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int32 -> Int32 -> prim () Source #

primAddrIndex :: Addr# -> Offset Int32 -> Int32 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Int32 -> prim Int32 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Int32 -> Int32 -> prim () Source #

PrimType Int64 Source # |

Methods

primSizeInBytes :: Proxy * Int64 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Int64 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Int64 -> Int64 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int64 -> prim Int64 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Int64 -> Int64 -> prim () Source #

primAddrIndex :: Addr# -> Offset Int64 -> Int64 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Int64 -> prim Int64 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Int64 -> Int64 -> prim () Source #

PrimType Word Source # |

Methods

primSizeInBytes :: Proxy * Word -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Word -> Int Source #

primBaUIndex :: ByteArray# -> Offset Word -> Word Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word -> prim Word Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word -> Word -> prim () Source #

primAddrIndex :: Addr# -> Offset Word -> Word Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Word -> prim Word Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Word -> Word -> prim () Source #

PrimType Word8 Source # |

Methods

primSizeInBytes :: Proxy * Word8 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Word8 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Word8 -> Word8 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word8 -> prim Word8 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word8 -> Word8 -> prim () Source #

primAddrIndex :: Addr# -> Offset Word8 -> Word8 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Word8 -> prim Word8 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Word8 -> Word8 -> prim () Source #

PrimType Word16 Source # |

Methods

primSizeInBytes :: Proxy * Word16 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Word16 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Word16 -> Word16 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word16 -> prim Word16 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word16 -> Word16 -> prim () Source #

primAddrIndex :: Addr# -> Offset Word16 -> Word16 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Word16 -> prim Word16 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Word16 -> Word16 -> prim () Source #

PrimType Word32 Source # |

Methods

primSizeInBytes :: Proxy * Word32 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Word32 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Word32 -> Word32 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word32 -> prim Word32 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word32 -> Word32 -> prim () Source #

primAddrIndex :: Addr# -> Offset Word32 -> Word32 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Word32 -> prim Word32 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Word32 -> Word32 -> prim () Source #

PrimType Word64 Source # |

Methods

primSizeInBytes :: Proxy * Word64 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Word64 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Word64 -> Word64 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word64 -> prim Word64 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word64 -> Word64 -> prim () Source #

primAddrIndex :: Addr# -> Offset Word64 -> Word64 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Word64 -> prim Word64 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Word64 -> Word64 -> prim () Source #

PrimType CChar Source # |

Methods

primSizeInBytes :: Proxy * CChar -> CountOf Word8 Source #

primShiftToBytes :: Proxy * CChar -> Int Source #

primBaUIndex :: ByteArray# -> Offset CChar -> CChar Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset CChar -> prim CChar Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset CChar -> CChar -> prim () Source #

primAddrIndex :: Addr# -> Offset CChar -> CChar Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset CChar -> prim CChar Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset CChar -> CChar -> prim () Source #

PrimType CUChar Source # |

Methods

primSizeInBytes :: Proxy * CUChar -> CountOf Word8 Source #

primShiftToBytes :: Proxy * CUChar -> Int Source #

primBaUIndex :: ByteArray# -> Offset CUChar -> CUChar Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset CUChar -> prim CUChar Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset CUChar -> CUChar -> prim () Source #

primAddrIndex :: Addr# -> Offset CUChar -> CUChar Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset CUChar -> prim CUChar Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset CUChar -> CUChar -> prim () Source #

PrimType Char7 Source # |

Methods

primSizeInBytes :: Proxy * Char7 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Char7 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Char7 -> Char7 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char7 -> prim Char7 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char7 -> Char7 -> prim () Source #

primAddrIndex :: Addr# -> Offset Char7 -> Char7 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Char7 -> prim Char7 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Char7 -> Char7 -> prim () Source #

PrimType Word128 Source # |

Methods

primSizeInBytes :: Proxy * Word128 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Word128 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Word128 -> Word128 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word128 -> prim Word128 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word128 -> Word128 -> prim () Source #

primAddrIndex :: Addr# -> Offset Word128 -> Word128 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Word128 -> prim Word128 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Word128 -> Word128 -> prim () Source #

PrimType Word256 Source # |

Methods

primSizeInBytes :: Proxy * Word256 -> CountOf Word8 Source #

primShiftToBytes :: Proxy * Word256 -> Int Source #

primBaUIndex :: ByteArray# -> Offset Word256 -> Word256 Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word256 -> prim Word256 Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Word256 -> Word256 -> prim () Source #

primAddrIndex :: Addr# -> Offset Word256 -> Word256 Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset Word256 -> prim Word256 Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset Word256 -> Word256 -> prim () Source #

PrimType a => PrimType (BE a) Source # |

Methods

primSizeInBytes :: Proxy * (BE a) -> CountOf Word8 Source #

primShiftToBytes :: Proxy * (BE a) -> Int Source #

primBaUIndex :: ByteArray# -> Offset (BE a) -> BE a Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (BE a) -> prim (BE a) Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (BE a) -> BE a -> prim () Source #

primAddrIndex :: Addr# -> Offset (BE a) -> BE a Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset (BE a) -> prim (BE a) Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset (BE a) -> BE a -> prim () Source #

PrimType a => PrimType (LE a) Source # |

Methods

primSizeInBytes :: Proxy * (LE a) -> CountOf Word8 Source #

primShiftToBytes :: Proxy * (LE a) -> Int Source #

primBaUIndex :: ByteArray# -> Offset (LE a) -> LE a Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (LE a) -> prim (LE a) Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (LE a) -> LE a -> prim () Source #

primAddrIndex :: Addr# -> Offset (LE a) -> LE a Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset (LE a) -> prim (LE a) Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset (LE a) -> LE a -> prim () Source #

# methods

copy :: PrimType ty => UArray ty -> UArray ty Source #

Copy every cells of an existing array to a new array

unsafeCopyAtRO Source #

Arguments

:: (PrimMonad prim, PrimType ty) |
=> MUArray ty (PrimState prim) | destination array
-> Offset ty | offset at destination
-> UArray ty | source array
-> Offset ty | offset at source
-> CountOf ty | number of elements to copy
-> prim () |

Copy `n` sequential elements from the specified offset in a source array to the specified position in a destination array.

This function does not check bounds. Accessing invalid memory can return unpredictable and invalid values.

# internal methods

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

unsafeRecast :: (PrimType a, PrimType b) => UArray a -> UArray b Source #

length :: UArray ty -> CountOf ty Source #

freeze :: (PrimType ty, PrimMonad prim) => MUArray ty (PrimState prim) -> prim (UArray ty) Source #

unsafeFreeze :: PrimMonad prim => MUArray ty (PrimState prim) -> prim (UArray ty) Source #

Freeze a mutable array into an array.

the MUArray must not be changed after freezing.

thaw :: (PrimMonad prim, PrimType ty) => UArray ty -> prim (MUArray ty (PrimState prim)) Source #

Thaw an array to a mutable array.

the array is not modified, instead a new mutable array is created and every values is copied, before returning the mutable array.

unsafeThaw :: (PrimType ty, PrimMonad prim) => UArray ty -> prim (MUArray ty (PrimState prim)) Source #

Thaw an immutable array.

The UArray must not be used after thawing.

# Creation

vFromListN :: forall ty. PrimType ty => CountOf ty -> [ty] -> UArray ty Source #

Make an array from a list of elements with a size hint.

The list should be of the same size as the hint, as otherwise:

- The length of the list is smaller than the hint: the array allocated is of the size of the hint, but is sliced to only represent the valid bits
- The length of the list is bigger than the hint: The allocated array is the size of the hint, and the list is truncated to fit.

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`.

create Source #

Arguments

:: PrimType ty |
=> CountOf ty | the size of the array
-> (Offset ty -> ty) | the function that set the value at the index
-> UArray ty | the array created

Create a new array of size `n by settings each cells through the function` f.

createFromIO Source #

Arguments

:: PrimType ty |
=> CountOf ty | the size of the array
-> (Ptr ty -> IO (CountOf ty)) | filling function that
-> IO (UArray ty) |

Create a pinned array that is filled by a `filler` function (typically an IO call like hGetBuf)

createFromPtr :: PrimType ty => Ptr ty -> CountOf ty -> IO (UArray ty) Source #

Freeze a chunk of memory pointed, of specific size into a new unboxed array

sub :: PrimType ty => UArray ty -> Offset ty -> Offset ty -> UArray ty Source #

copyToPtr Source #

Arguments

:: (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

withPtr :: forall ty prim a. (PrimMonad prim, PrimType ty) => UArray ty -> (Ptr ty -> prim a) -> prim a Source #

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.

unsafeFreezeShrink :: (PrimType ty, PrimMonad prim) => MUArray ty (PrimState prim) -> CountOf ty -> prim (UArray ty) Source #

freezeShrink :: (PrimType ty, PrimMonad prim) => MUArray ty (PrimState prim) -> CountOf ty -> prim (UArray ty) Source #

fromBlock :: PrimType ty => Block ty -> UArray ty Source #

Create a UArray from a Block

The block is still used by the uarray

toBlock :: PrimType ty => UArray ty -> Block ty Source #

Create a Block from a UArray.

Note that because of the slice, the destination block is re-allocated and copied, unless the slice point at the whole array

# accessors

update :: PrimType ty => UArray ty -> [(Offset ty, ty)] -> UArray ty Source #

update an array by creating a new array with the updates.

the operation copy the previous array, modify it in place, then freeze it.

unsafeUpdate :: PrimType ty => UArray ty -> [(Offset ty, ty)] -> UArray ty Source #

unsafeIndex :: forall ty. PrimType ty => UArray ty -> Offset ty -> ty Source #

Return the element at a specific index from an array without bounds checking.

Reading from invalid memory can return unpredictable and invalid values. use `index` if unsure.

unsafeIndexer :: (PrimMonad prim, PrimType ty) => UArray ty -> ((Offset ty -> ty) -> prim a) -> prim a Source #

unsafeDewrap :: (ByteArray# -> Offset ty -> a) -> (Ptr ty -> Offset ty -> ST s a) -> UArray ty -> a Source #

unsafeRead :: (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> Offset ty -> prim ty Source #

read from a cell in a mutable array without bounds checking.

Reading from invalid memory can return unpredictable and invalid values. use `read` if unsure.

unsafeWrite :: (PrimMonad prim, PrimType ty) => MUArray ty (PrimState prim) -> Offset ty -> ty -> prim () Source #

write to a cell in a mutable array without bounds checking.

Writing with invalid bounds will corrupt memory and your program will become unreliable. use `write` if unsure.

# Functions

equalMemcmp :: PrimType ty => UArray ty -> UArray ty -> Bool Source #

singleton :: PrimType ty => ty -> UArray ty Source #

replicate :: PrimType ty => CountOf ty -> ty -> UArray ty Source #

map :: (PrimType a, PrimType b) => (a -> b) -> UArray a -> UArray b Source #

mapIndex :: (PrimType a, PrimType b) => (Offset b -> a -> b) -> UArray a -> UArray b Source #

findIndex :: PrimType ty => ty -> UArray ty -> Maybe (Offset ty) Source #

revFindIndex :: PrimType ty => ty -> UArray ty -> Maybe (Offset ty) Source #

index :: PrimType ty => UArray ty -> Offset ty -> ty Source #

Return the element at a specific index from an array.

If the index @n is out of bounds, an error is raised.

null :: UArray ty -> Bool Source #

take :: CountOf ty -> UArray ty -> UArray ty Source #

Take a count of elements from the array and create an array with just those elements

unsafeTake :: CountOf ty -> UArray ty -> UArray ty Source #

drop :: CountOf ty -> UArray ty -> UArray ty Source #

Drop a count of elements from the array and return the new array minus those dropped elements

unsafeDrop :: CountOf ty -> UArray ty -> UArray ty Source #

splitAt :: CountOf ty -> UArray ty -> (UArray ty, UArray ty) Source #

Split an array into two, with a count of at most N elements in the first one and the remaining in the other.

revDrop :: CountOf ty -> UArray ty -> UArray ty Source #

Drop the N elements from the end of the array

revTake :: CountOf ty -> UArray ty -> UArray ty Source #

Take the N elements from the end of the array

revSplitAt :: CountOf ty -> UArray ty -> (UArray ty, UArray ty) Source #

Split an array at the N element from the end, and return the last N elements in the first part of the tuple, and whatever first elements remaining in the second

splitOn :: PrimType ty => (ty -> Bool) -> UArray ty -> [UArray ty] Source #

break :: forall ty. PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty) Source #

breakEnd :: forall ty. PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty) Source #

Similar to break but start the search of the breakpoint from the end

    breakEnd (> 0) [1,2,3,0,0,0]

([1,2,3], [0,0,0])

breakElem :: PrimType ty => ty -> UArray ty -> (UArray ty, UArray ty) Source #

breakLine :: UArray Word8 -> Either Bool (UArray Word8, UArray Word8) Source #

Similar to breakElem specialized to split on linefeed

it either returns: * Left. no line has been found, and whether the last character is a CR * Right, a line has been found with an optional CR, and it returns the array of bytes on the left of the CR/LF, and the the array of bytes on the right of the LF.

elem :: PrimType ty => ty -> UArray ty -> Bool Source #

indices :: PrimType ty => UArray ty -> UArray ty -> [Offset ty] Source #

intersperse :: forall ty. PrimType ty => ty -> UArray ty -> UArray ty Source #

span :: PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty) Source #

spanEnd :: PrimType ty => (ty -> Bool) -> UArray ty -> (UArray ty, UArray ty) Source #

cons :: PrimType ty => ty -> UArray ty -> UArray ty Source #

snoc :: PrimType ty => UArray ty -> ty -> UArray ty Source #

uncons :: PrimType ty => UArray ty -> Maybe (ty, UArray ty) Source #

unsnoc :: PrimType ty => UArray ty -> Maybe (UArray ty, ty) Source #

find :: PrimType ty => (ty -> Bool) -> UArray ty -> Maybe ty Source #

sortBy :: forall ty. PrimType ty => (ty -> ty -> Ordering) -> UArray ty -> UArray ty Source #

filter :: forall ty. PrimType ty => (ty -> Bool) -> UArray ty -> UArray ty Source #

reverse :: forall ty. PrimType ty => UArray ty -> UArray ty Source #

replace :: PrimType ty => UArray ty -> UArray ty -> UArray ty -> UArray ty Source #

Replace all the occurrencies of `needle` with `replacement` in the `haystack` string.

foldr :: PrimType ty => (ty -> a -> a) -> a -> UArray ty -> a Source #

foldl' :: PrimType ty => (a -> ty -> a) -> a -> UArray ty -> a Source #

foldr1 :: PrimType ty => (ty -> ty -> ty) -> NonEmpty (UArray ty) -> ty Source #

foldl1' :: PrimType ty => (ty -> ty -> ty) -> NonEmpty (UArray ty) -> ty Source #

all :: PrimType ty => (ty -> Bool) -> UArray ty -> Bool Source #

any :: PrimType ty => (ty -> Bool) -> UArray ty -> Bool Source #

isPrefixOf :: PrimType ty => UArray ty -> UArray ty -> Bool Source #

isSuffixOf :: PrimType ty => UArray ty -> UArray ty -> Bool Source #

foreignMem Source #

Arguments

:: PrimType ty |
=> FinalPtr ty | the start pointer with a finalizer
-> CountOf ty | the number of elements (in elements, not bytes)
-> UArray ty |

fromForeignPtr :: PrimType ty => (ForeignPtr ty, Int, Int) -> UArray ty Source #

builderAppend :: (PrimType ty, PrimMonad state) => ty -> Builder (UArray ty) (MUArray ty) ty state err () Source #

builderBuild :: (PrimType ty, PrimMonad m) => Int -> Builder (UArray ty) (MUArray ty) ty m err () -> m (Either err (UArray ty)) Source #

builderBuild_ :: (PrimType ty, PrimMonad m) => Int -> Builder (UArray ty) (MUArray ty) ty m () () -> m (UArray ty) Source #

toHexadecimal :: PrimType ty => UArray ty -> UArray Word8 Source #

toBase64Internal :: PrimType ty => Addr# -> UArray ty -> Bool -> UArray Word8 Source #