Copyright | (c) Dong Han 2017 |
---|---|
License | BSD |
Maintainer | winterland1989@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Unified unboxed and boxed array operations using functional dependencies.
All operations are NOT bound checked, if you need checked operations please use Z.Data.Array.Checked. It exports exactly same APIs so that you can switch between without pain.
Some mnemonics:
newArr
,newArrWith
return mutable array,readArr
,writeArr
works on them,setArr
fill elements with offset and length.indexArr
works on immutable one, useindexArr'
to avoid indexing thunk.- The order of arguements of
copyArr
,copyMutableArr
andmoveArr
are always target and its offset come first, and source and source offset follow, copying length comes last.
Synopsis
- class Arr (arr :: * -> *) a where
- type MArr arr = (mar :: * -> * -> *) | mar -> arr
- newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MArr arr s a)
- newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MArr arr s a)
- readArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> m a
- writeArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> a -> m ()
- setArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> Int -> a -> m ()
- indexArr :: arr a -> Int -> a
- indexArr' :: arr a -> Int -> (# a #)
- indexArrM :: Monad m => arr a -> Int -> m a
- freezeArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> Int -> m (arr a)
- thawArr :: (PrimMonad m, PrimState m ~ s) => arr a -> Int -> Int -> m (MArr arr s a)
- unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> m (arr a)
- unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => arr a -> m (MArr arr s a)
- copyArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> arr a -> Int -> Int -> m ()
- copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> MArr arr s a -> Int -> Int -> m ()
- moveArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> MArr arr s a -> Int -> Int -> m ()
- cloneArr :: arr a -> Int -> Int -> arr a
- cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> Int -> m (MArr arr s a)
- resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> m (MArr arr s a)
- shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> m ()
- sameMutableArr :: MArr arr s a -> MArr arr s a -> Bool
- sizeofArr :: arr a -> Int
- sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> m Int
- sameArr :: arr a -> arr a -> Bool
- data RealWorld
- data Array a = Array {}
- data MutableArray s a = MutableArray {
- marray# :: MutableArray# s a
- data SmallArray a = SmallArray (SmallArray# a)
- data SmallMutableArray s a = SmallMutableArray (SmallMutableArray# s a)
- uninitialized :: a
- data PrimArray a = PrimArray ByteArray#
- data MutablePrimArray s a = MutablePrimArray (MutableByteArray# s)
- class Prim a where
- sizeOf# :: a -> Int#
- alignment# :: a -> Int#
- indexByteArray# :: ByteArray# -> Int# -> a
- readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, a #)
- writeByteArray# :: MutableByteArray# s -> Int# -> a -> State# s -> State# s
- setByteArray# :: MutableByteArray# s -> Int# -> Int# -> a -> State# s -> State# s
- indexOffAddr# :: Addr# -> Int# -> a
- readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, a #)
- writeOffAddr# :: Addr# -> Int# -> a -> State# s -> State# s
- setOffAddr# :: Addr# -> Int# -> Int# -> a -> State# s -> State# s
- newPinnedPrimArray :: (PrimMonad m, Prim a) => Int -> m (MutablePrimArray (PrimState m) a)
- newAlignedPinnedPrimArray :: (PrimMonad m, Prim a) => Int -> m (MutablePrimArray (PrimState m) a)
- copyPrimArrayToPtr :: (PrimMonad m, Prim a) => Ptr a -> PrimArray a -> Int -> Int -> m ()
- copyMutablePrimArrayToPtr :: (PrimMonad m, Prim a) => Ptr a -> MutablePrimArray (PrimState m) a -> Int -> Int -> m ()
- copyPtrToMutablePrimArray :: (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> Int -> Ptr a -> Int -> m ()
- primArrayContents :: PrimArray a -> Ptr a
- mutablePrimArrayContents :: MutablePrimArray s a -> Ptr a
- withPrimArrayContents :: PrimArray a -> (Ptr a -> IO b) -> IO b
- withMutablePrimArrayContents :: MutablePrimArray RealWorld a -> (Ptr a -> IO b) -> IO b
- isPrimArrayPinned :: PrimArray a -> Bool
- isMutablePrimArrayPinned :: MutablePrimArray s a -> Bool
- data UnliftedArray a = UnliftedArray ArrayArray#
- data MutableUnliftedArray s a = MutableUnliftedArray (MutableArrayArray# s)
- class PrimUnlifted a where
- writeUnliftedArray# :: MutableArrayArray# s -> Int# -> a -> State# s -> State# s
- readUnliftedArray# :: MutableArrayArray# s -> Int# -> State# s -> (# State# s, a #)
- indexUnliftedArray# :: ArrayArray# -> Int# -> a
- data ArrayException
- class Cast source destination
- castArray :: (Arr arr a, Cast a b) => arr a -> arr b
- castMutableArray :: (Arr arr a, Cast a b) => MArr arr s a -> MArr arr s b
Arr typeclass
class Arr (arr :: * -> *) a where Source #
A typeclass to unify box & unboxed, mutable & immutable array operations.
Most of these functions simply wrap their primitive counterpart, if there's no primitive ones, we polyfilled using other operations to get the same semantics.
One exception is that shrinkMutableArr
only perform closure resizing on PrimArray
because
current RTS support only that, shrinkMutableArr
will do nothing on other array type.
It's reasonable to trust GHC with specializing & inlining these polymorphric functions. They are used across this package and perform identical to their monomophric counterpart.
newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MArr arr s a) Source #
Make a new array with given size.
For boxed array, all elements are uninitialized
which shall not be accessed.
For primitive array, elements are just random garbage.
newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MArr arr s a) Source #
Make a new array and fill it with an initial value.
readArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> m a Source #
Index mutable array in a primitive monad.
writeArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> a -> m () Source #
Write mutable array in a primitive monad.
setArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> Int -> a -> m () Source #
Fill mutable array with a given value.
indexArr :: arr a -> Int -> a Source #
Index immutable array, which is a pure operation. This operation often
result in an indexing thunk for lifted arrays, use 'indexArr'' or indexArrM
if that's not desired.
indexArr' :: arr a -> Int -> (# a #) Source #
Index immutable array, pattern match on the unboxed unit tuple to force indexing (without forcing the element).
indexArrM :: Monad m => arr a -> Int -> m a Source #
Index immutable array in a primitive monad, this helps in situations that you want your indexing result is not a thunk referencing whole array.
freezeArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> Int -> m (arr a) Source #
Safely freeze mutable array by make a immutable copy of its slice.
thawArr :: (PrimMonad m, PrimState m ~ s) => arr a -> Int -> Int -> m (MArr arr s a) Source #
Safely thaw immutable array by make a mutable copy of its slice.
unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> m (arr a) Source #
In place freeze a mutable array, the original mutable array can not be used anymore.
unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => arr a -> m (MArr arr s a) Source #
In place thaw a immutable array, the original immutable array can not be used anymore.
:: (PrimMonad m, PrimState m ~ s) | |
=> MArr arr s a | target |
-> Int | target offset |
-> arr a | source |
-> Int | source offset |
-> Int | source length |
-> m () |
Copy a slice of immutable array to mutable array at given offset.
:: (PrimMonad m, PrimState m ~ s) | |
=> MArr arr s a | target |
-> Int | target offset |
-> MArr arr s a | source |
-> Int | source offset |
-> Int | source length |
-> m () |
Copy a slice of mutable array to mutable array at given offset. The two mutable arrays shall no be the same one.
:: (PrimMonad m, PrimState m ~ s) | |
=> MArr arr s a | target |
-> Int | target offset |
-> MArr arr s a | source |
-> Int | source offset |
-> Int | source length |
-> m () |
Copy a slice of mutable array to mutable array at given offset. The two mutable arrays may be the same one.
cloneArr :: arr a -> Int -> Int -> arr a Source #
Create immutable copy.
cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> Int -> m (MArr arr s a) Source #
Create mutable copy.
resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> m (MArr arr s a) Source #
Resize mutable array to given size.
shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> Int -> m () Source #
Shrink mutable array to given size. This operation only works on primitive arrays.
For some array types, this is a no-op, e.g. sizeOfMutableArr
will not change.
sameMutableArr :: MArr arr s a -> MArr arr s a -> Bool Source #
Is two mutable array are reference equal.
sizeofArr :: arr a -> Int Source #
Size of immutable array.
sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr arr s a -> m Int Source #
Size of mutable array.
sameArr :: arr a -> arr a -> Bool Source #
Is two immutable array are referencing the same one.
Note that sameArr
's result may change depending on compiler's optimizations, for example
let arr = runST ... in arr
may return false if compiler decides to
inline it.sameArr
arr
See https://ghc.haskell.org/trac/ghc/ticket/13908 for more background.
Instances
Prim a => Arr PrimArray a Source # | |
Defined in Z.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MArr PrimArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MArr PrimArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> Int -> a -> m () Source # indexArr :: PrimArray a -> Int -> a Source # indexArr' :: PrimArray a -> Int -> (# a #) Source # indexArrM :: Monad m => PrimArray a -> Int -> m a Source # freezeArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> Int -> m (PrimArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => PrimArray a -> Int -> Int -> m (MArr PrimArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> m (PrimArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => PrimArray a -> m (MArr PrimArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> PrimArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> MArr PrimArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> MArr PrimArray s a -> Int -> Int -> m () Source # cloneArr :: PrimArray a -> Int -> Int -> PrimArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> Int -> m (MArr PrimArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> m (MArr PrimArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> Int -> m () Source # sameMutableArr :: MArr PrimArray s a -> MArr PrimArray s a -> Bool Source # sizeofArr :: PrimArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr PrimArray s a -> m Int Source # | |
PrimUnlifted a => Arr UnliftedArray a Source # | |
Defined in Z.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MArr UnliftedArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MArr UnliftedArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> Int -> a -> m () Source # indexArr :: UnliftedArray a -> Int -> a Source # indexArr' :: UnliftedArray a -> Int -> (# a #) Source # indexArrM :: Monad m => UnliftedArray a -> Int -> m a Source # freezeArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> Int -> m (UnliftedArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => UnliftedArray a -> Int -> Int -> m (MArr UnliftedArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> m (UnliftedArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => UnliftedArray a -> m (MArr UnliftedArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> UnliftedArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> MArr UnliftedArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> MArr UnliftedArray s a -> Int -> Int -> m () Source # cloneArr :: UnliftedArray a -> Int -> Int -> UnliftedArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> Int -> m (MArr UnliftedArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> m (MArr UnliftedArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> Int -> m () Source # sameMutableArr :: MArr UnliftedArray s a -> MArr UnliftedArray s a -> Bool Source # sizeofArr :: UnliftedArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr UnliftedArray s a -> m Int Source # sameArr :: UnliftedArray a -> UnliftedArray a -> Bool Source # | |
Arr Array a Source # | |
Defined in Z.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MArr Array s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MArr Array s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Int -> a -> m () Source # indexArr :: Array a -> Int -> a Source # indexArr' :: Array a -> Int -> (# a #) Source # indexArrM :: Monad m => Array a -> Int -> m a Source # freezeArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Int -> m (Array a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> Int -> Int -> m (MArr Array s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> m (Array a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> m (MArr Array s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Array a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> MArr Array s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> MArr Array s a -> Int -> Int -> m () Source # cloneArr :: Array a -> Int -> Int -> Array a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Int -> m (MArr Array s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> m (MArr Array s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> m () Source # sameMutableArr :: MArr Array s a -> MArr Array s a -> Bool Source # sizeofArr :: Array a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> m Int Source # | |
Arr SmallArray a Source # | |
Defined in Z.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MArr SmallArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MArr SmallArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> Int -> a -> m () Source # indexArr :: SmallArray a -> Int -> a Source # indexArr' :: SmallArray a -> Int -> (# a #) Source # indexArrM :: Monad m => SmallArray a -> Int -> m a Source # freezeArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> Int -> m (SmallArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => SmallArray a -> Int -> Int -> m (MArr SmallArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> m (SmallArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => SmallArray a -> m (MArr SmallArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> SmallArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> MArr SmallArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> MArr SmallArray s a -> Int -> Int -> m () Source # cloneArr :: SmallArray a -> Int -> Int -> SmallArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> Int -> m (MArr SmallArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> m (MArr SmallArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> Int -> m () Source # sameMutableArr :: MArr SmallArray s a -> MArr SmallArray s a -> Bool Source # sizeofArr :: SmallArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr SmallArray s a -> m Int Source # sameArr :: SmallArray a -> SmallArray a -> Bool Source # |
RealWorld
is deeply magical. It is primitive, but it is not
unlifted (hence ptrArg
). We never manipulate values of type
RealWorld
; it's only used in the type system, to parameterise State#
.
Boxed array type
Instances
Monad Array | |
Functor Array | |
MonadFix Array | |
Defined in Data.Primitive.Array | |
MonadFail Array | |
Defined in Data.Primitive.Array | |
Applicative Array | |
Foldable Array | |
Defined in Data.Primitive.Array fold :: Monoid m => Array m -> m # foldMap :: Monoid m => (a -> m) -> Array a -> m # foldMap' :: Monoid m => (a -> m) -> Array a -> m # foldr :: (a -> b -> b) -> b -> Array a -> b # foldr' :: (a -> b -> b) -> b -> Array a -> b # foldl :: (b -> a -> b) -> b -> Array a -> b # foldl' :: (b -> a -> b) -> b -> Array a -> b # foldr1 :: (a -> a -> a) -> Array a -> a # foldl1 :: (a -> a -> a) -> Array a -> a # elem :: Eq a => a -> Array a -> Bool # maximum :: Ord a => Array a -> a # minimum :: Ord a => Array a -> a # | |
Traversable Array | |
Eq1 Array | |
Ord1 Array | |
Defined in Data.Primitive.Array | |
Read1 Array | |
Defined in Data.Primitive.Array | |
Show1 Array | |
MonadZip Array | |
Alternative Array | |
MonadPlus Array | |
NFData1 Array | |
Defined in Data.Primitive.Array | |
Arr Array a Source # | |
Defined in Z.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MArr Array s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MArr Array s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Int -> a -> m () Source # indexArr :: Array a -> Int -> a Source # indexArr' :: Array a -> Int -> (# a #) Source # indexArrM :: Monad m => Array a -> Int -> m a Source # freezeArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Int -> m (Array a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> Int -> Int -> m (MArr Array s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> m (Array a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> m (MArr Array s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Array a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> MArr Array s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> MArr Array s a -> Int -> Int -> m () Source # cloneArr :: Array a -> Int -> Int -> Array a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> Int -> m (MArr Array s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> m (MArr Array s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> Int -> m () Source # sameMutableArr :: MArr Array s a -> MArr Array s a -> Bool Source # sizeofArr :: Array a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MArr Array s a -> m Int Source # | |
Vec Array a Source # | |
IsList (Array a) | |
Eq a => Eq (Array a) | |
Data a => Data (Array a) | |
Defined in Data.Primitive.Array gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Array a -> c (Array a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Array a) # toConstr :: Array a -> Constr # dataTypeOf :: Array a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Array a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Array a)) # gmapT :: (forall b. Data b => b -> b) -> Array a -> Array a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Array a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Array a -> r # gmapQ :: (forall d. Data d => d -> u) -> Array a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Array a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Array a -> m (Array a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Array a -> m (Array a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Array a -> m (Array a) # | |
Ord a => Ord (Array a) | |
Read a => Read (Array a) | |
Show a => Show (Array a) | |
Semigroup (Array a) | |
Monoid (Array a) | |
NFData a => NFData (Array a) | |
Defined in Data.Primitive.Array | |
type MArr Array Source # | |
Defined in Z.Data.Array | |
type IArray Array Source # | |
Defined in Z.Data.Vector.Base | |
type Item (Array a) | |
Defined in Data.Primitive.Array |
data MutableArray s a #
MutableArray | |
|
Instances
Eq (MutableArray s a) | |
Defined in Data.Primitive.Array (==) :: MutableArray s a -> MutableArray s a -> Bool # (/=) :: MutableArray s a -> MutableArray s a -> Bool # | |
(Typeable s, Typeable a) => Data (MutableArray s a) | |
Defined in Data.Primitive.Array gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MutableArray s a -> c (MutableArray s a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MutableArray s a) # toConstr :: MutableArray s a -> Constr # dataTypeOf :: MutableArray s a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MutableArray s a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MutableArray s a)) # gmapT :: (forall b. Data b => b -> b) -> MutableArray s a -> MutableArray s a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MutableArray s a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MutableArray s a -> r # gmapQ :: (forall d. Data d => d -> u) -> MutableArray s a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MutableArray s a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MutableArray s a -> m (MutableArray s a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MutableArray s a -> m (MutableArray s a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MutableArray s a -> m (MutableArray s a) # |
data SmallArray a #
Instances
data SmallMutableArray s a #
Instances
Eq (SmallMutableArray s a) | |
Defined in Data.Primitive.SmallArray (==) :: SmallMutableArray s a -> SmallMutableArray s a -> Bool # (/=) :: SmallMutableArray s a -> SmallMutableArray s a -> Bool # | |
(Typeable s, Typeable a) => Data (SmallMutableArray s a) | |
Defined in Data.Primitive.SmallArray gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SmallMutableArray s a -> c (SmallMutableArray s a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (SmallMutableArray s a) # toConstr :: SmallMutableArray s a -> Constr # dataTypeOf :: SmallMutableArray s a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (SmallMutableArray s a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (SmallMutableArray s a)) # gmapT :: (forall b. Data b => b -> b) -> SmallMutableArray s a -> SmallMutableArray s a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SmallMutableArray s a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SmallMutableArray s a -> r # gmapQ :: (forall d. Data d => d -> u) -> SmallMutableArray s a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SmallMutableArray s a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SmallMutableArray s a -> m (SmallMutableArray s a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SmallMutableArray s a -> m (SmallMutableArray s a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SmallMutableArray s a -> m (SmallMutableArray s a) # |
uninitialized :: a Source #
Bottom value (throw (
)
for initialize new boxed array(UndefinedElement
"Data.Array.uninitialized")Array
, SmallArray
..).
Primitive array type
Instances
data MutablePrimArray s a #
Instances
Eq (MutablePrimArray s a) | |
Defined in Data.Primitive.PrimArray (==) :: MutablePrimArray s a -> MutablePrimArray s a -> Bool # (/=) :: MutablePrimArray s a -> MutablePrimArray s a -> Bool # | |
NFData (MutablePrimArray s a) | |
Defined in Data.Primitive.PrimArray rnf :: MutablePrimArray s a -> () # | |
PrimUnlifted (MutablePrimArray s a) Source # | |
Defined in Z.Data.Array.UnliftedArray writeUnliftedArray# :: MutableArrayArray# s0 -> Int# -> MutablePrimArray s a -> State# s0 -> State# s0 Source # readUnliftedArray# :: MutableArrayArray# s0 -> Int# -> State# s0 -> (# State# s0, MutablePrimArray s a #) Source # indexUnliftedArray# :: ArrayArray# -> Int# -> MutablePrimArray s a Source # |
alignment# :: a -> Int# #
indexByteArray# :: ByteArray# -> Int# -> a #
readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, a #) #
writeByteArray# :: MutableByteArray# s -> Int# -> a -> State# s -> State# s #
setByteArray# :: MutableByteArray# s -> Int# -> Int# -> a -> State# s -> State# s #
indexOffAddr# :: Addr# -> Int# -> a #
readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, a #) #
writeOffAddr# :: Addr# -> Int# -> a -> State# s -> State# s #
setOffAddr# :: Addr# -> Int# -> Int# -> a -> State# s -> State# s #
Instances
newPinnedPrimArray :: (PrimMonad m, Prim a) => Int -> m (MutablePrimArray (PrimState m) a) #
newAlignedPinnedPrimArray :: (PrimMonad m, Prim a) => Int -> m (MutablePrimArray (PrimState m) a) #
copyMutablePrimArrayToPtr :: (PrimMonad m, Prim a) => Ptr a -> MutablePrimArray (PrimState m) a -> Int -> Int -> m () #
copyPtrToMutablePrimArray :: (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> Int -> Ptr a -> Int -> m () #
primArrayContents :: PrimArray a -> Ptr a #
mutablePrimArrayContents :: MutablePrimArray s a -> Ptr a #
withPrimArrayContents :: PrimArray a -> (Ptr a -> IO b) -> IO b Source #
Yield a pointer to the array's data and do computation with it.
This operation is only safe on pinned primitive arrays allocated by newPinnedPrimArray
or
newAlignedPinnedPrimArray
.
Don't pass a forever loop to this function, see #14346.
withMutablePrimArrayContents :: MutablePrimArray RealWorld a -> (Ptr a -> IO b) -> IO b Source #
Yield a pointer to the array's data and do computation with it.
This operation is only safe on pinned primitive arrays allocated by newPinnedPrimArray
or
newAlignedPinnedPrimArray
.
Don't pass a forever loop to this function, see #14346.
isPrimArrayPinned :: PrimArray a -> Bool #
isMutablePrimArrayPinned :: MutablePrimArray s a -> Bool #
Unlifted array type
data UnliftedArray a Source #
Instances
class PrimUnlifted a where Source #
writeUnliftedArray# :: MutableArrayArray# s -> Int# -> a -> State# s -> State# s Source #
readUnliftedArray# :: MutableArrayArray# s -> Int# -> State# s -> (# State# s, a #) Source #
indexUnliftedArray# :: ArrayArray# -> Int# -> a Source #
Instances
The ArrayException
type
data ArrayException #
Exceptions generated by array operations
IndexOutOfBounds String | An attempt was made to index an array outside its declared bounds. |
UndefinedElement String | An attempt was made to evaluate an element of an array that had not been initialized. |
Instances
Eq ArrayException | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception (==) :: ArrayException -> ArrayException -> Bool # (/=) :: ArrayException -> ArrayException -> Bool # | |
Ord ArrayException | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception compare :: ArrayException -> ArrayException -> Ordering # (<) :: ArrayException -> ArrayException -> Bool # (<=) :: ArrayException -> ArrayException -> Bool # (>) :: ArrayException -> ArrayException -> Bool # (>=) :: ArrayException -> ArrayException -> Bool # max :: ArrayException -> ArrayException -> ArrayException # min :: ArrayException -> ArrayException -> ArrayException # | |
Show ArrayException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception showsPrec :: Int -> ArrayException -> ShowS # show :: ArrayException -> String # showList :: [ArrayException] -> ShowS # | |
Exception ArrayException | Since: base-4.1.0.0 |
Defined in GHC.IO.Exception |
Cast between primitive arrays
class Cast source destination Source #
Cast
between primitive types of the same size.
Instances
Cast Double Int64 Source # | |
Cast Double Word64 Source # | |
Cast Float Int32 Source # | |
Cast Float Word32 Source # | |
Cast Int Word Source # | |
Cast Int8 Word8 Source # | |
Cast Int16 Word16 Source # | |
Cast Int32 Float Source # | |
Cast Int32 Word32 Source # | |
Cast Int64 Double Source # | |
Cast Int64 Word64 Source # | |
Cast Word Int Source # | |
Cast Word8 Int8 Source # | |
Cast Word16 Int16 Source # | |
Cast Word32 Float Source # | |
Cast Word32 Int32 Source # | |
Cast Word64 Double Source # | |
Cast Word64 Int64 Source # | |
Coercible a b => Cast a b Source # | |
Defined in Z.Data.Array.Cast |