Copyright | (c) Dong Han 2017-2019 |
---|---|
License | BSD |
Maintainer | winterland1989@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This module provides exactly the same API with Std.Data.Array, but will throw an IndexOutOfBounds
ArrayException
on bound check failure, it's useful when debugging array algorithms: just swap this
module with Std.Data.Array, segmentation faults caused by out bound access will be turned into exceptions
with more informations.
Synopsis
- class Arr (marr :: * -> * -> *) (arr :: * -> *) a | arr -> marr, marr -> arr
- data RealWorld :: Type
- newArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => Int -> m (marr s a)
- newArrWith :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => Int -> a -> m (marr s a)
- readArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> m a
- writeArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> a -> m ()
- setArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> Int -> a -> m ()
- indexArr :: (Arr marr arr a, HasCallStack) => arr a -> Int -> a
- indexArr' :: (Arr marr arr a, HasCallStack) => arr a -> Int -> (#a#)
- indexArrM :: (Arr marr arr a, Monad m, HasCallStack) => arr a -> Int -> m a
- freezeArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> Int -> m (arr a)
- thawArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => arr a -> Int -> Int -> m (marr s a)
- copyArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> arr a -> Int -> Int -> m ()
- copyMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> marr s a -> Int -> Int -> m ()
- moveArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> marr s a -> Int -> Int -> m ()
- cloneArr :: (Arr marr arr a, HasCallStack) => arr a -> Int -> Int -> arr a
- cloneMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> Int -> m (marr s a)
- resizeMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> m (marr s a)
- shrinkMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> m ()
- unsafeFreezeArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s) => marr s a -> m (arr a)
- unsafeThawArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s) => arr a -> m (marr s a)
- sameMutableArr :: Arr marr arr a => marr s a -> marr s a -> Bool
- sizeofArr :: Arr marr arr a => arr a -> Int
- sizeofMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s) => marr s a -> m Int
- sameArr :: Arr marr arr a => arr a -> arr a -> Bool
- 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)
- newPinnedPrimArray :: (PrimMonad m, Prim a, HasCallStack) => Int -> m (MutablePrimArray (PrimState m) a)
- newAlignedPinnedPrimArray :: (PrimMonad m, Prim a, HasCallStack) => Int -> m (MutablePrimArray (PrimState m) a)
- copyPrimArrayToPtr :: (PrimMonad m, Prim a, HasCallStack) => Ptr a -> PrimArray a -> Int -> Int -> m ()
- copyMutablePrimArrayToPtr :: (PrimMonad m, Prim a, HasCallStack) => Ptr a -> MutablePrimArray (PrimState m) a -> Int -> Int -> m ()
- copyPtrToMutablePrimArray :: (PrimMonad m, Prim a, HasCallStack) => 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 e = UnliftedArray ArrayArray#
- data MutableUnliftedArray s e = MutableUnliftedArray (MutableArrayArray# s)
- class PrimUnlifted a where
- toArrayArray# :: a -> ArrayArray#
- fromArrayArray# :: ArrayArray# -> a
- data ArrayException
Arr typeclass re-export
class Arr (marr :: * -> * -> *) (arr :: * -> *) a | arr -> marr, marr -> arr 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, newArrWith, readArr, writeArr, setArr, indexArr, indexArr', indexArrM, freezeArr, thawArr, unsafeFreezeArr, unsafeThawArr, copyArr, copyMutableArr, moveArr, cloneArr, cloneMutableArr, resizeMutableArr, shrinkMutableArr, sameMutableArr, sizeofArr, sizeofMutableArr, sameArr
Instances
Prim a => Arr MutablePrimArray PrimArray a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MutablePrimArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MutablePrimArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray 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) => MutablePrimArray s a -> Int -> Int -> m (PrimArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => PrimArray a -> Int -> Int -> m (MutablePrimArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> m (PrimArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => PrimArray a -> m (MutablePrimArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> PrimArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> MutablePrimArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> MutablePrimArray s a -> Int -> Int -> m () Source # cloneArr :: PrimArray a -> Int -> Int -> PrimArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> Int -> m (MutablePrimArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> m (MutablePrimArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> m () Source # sameMutableArr :: MutablePrimArray s a -> MutablePrimArray s a -> Bool Source # sizeofArr :: PrimArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> m Int Source # | |
Arr MutableArray Array a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MutableArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MutableArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MutableArray 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) => MutableArray s a -> Int -> Int -> m (Array a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> Int -> Int -> m (MutableArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> m (Array a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> m (MutableArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> Array a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> MutableArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> MutableArray s a -> Int -> Int -> m () Source # cloneArr :: Array a -> Int -> Int -> Array a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> Int -> m (MutableArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m (MutableArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m () Source # sameMutableArr :: MutableArray s a -> MutableArray s a -> Bool Source # sizeofArr :: Array a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> m Int Source # | |
Arr SmallMutableArray SmallArray a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (SmallMutableArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (SmallMutableArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray 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) => SmallMutableArray s a -> Int -> Int -> m (SmallArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => SmallArray a -> Int -> Int -> m (SmallMutableArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> m (SmallArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => SmallArray a -> m (SmallMutableArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> SmallArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> SmallMutableArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> SmallMutableArray s a -> Int -> Int -> m () Source # cloneArr :: SmallArray a -> Int -> Int -> SmallArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> Int -> m (SmallMutableArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> m (SmallMutableArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> m () Source # sameMutableArr :: SmallMutableArray s a -> SmallMutableArray s a -> Bool Source # sizeofArr :: SmallArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> m Int Source # sameArr :: SmallArray a -> SmallArray a -> Bool Source # | |
PrimUnlifted a => Arr MutableUnliftedArray UnliftedArray a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MutableUnliftedArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MutableUnliftedArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray 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) => MutableUnliftedArray s a -> Int -> Int -> m (UnliftedArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => UnliftedArray a -> Int -> Int -> m (MutableUnliftedArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> m (UnliftedArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => UnliftedArray a -> m (MutableUnliftedArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> UnliftedArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> MutableUnliftedArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> MutableUnliftedArray s a -> Int -> Int -> m () Source # cloneArr :: UnliftedArray a -> Int -> Int -> UnliftedArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> Int -> m (MutableUnliftedArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> m (MutableUnliftedArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> Int -> m () Source # sameMutableArr :: MutableUnliftedArray s a -> MutableUnliftedArray s a -> Bool Source # sizeofArr :: UnliftedArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableUnliftedArray s a -> m Int Source # sameArr :: UnliftedArray a -> UnliftedArray 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#
.
Bound checked array operations
newArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => Int -> m (marr s a) Source #
newArrWith :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => Int -> a -> m (marr s a) Source #
readArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> m a Source #
writeArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> a -> m () Source #
setArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> Int -> a -> m () Source #
freezeArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> Int -> m (arr a) Source #
thawArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => arr a -> Int -> Int -> m (marr s a) Source #
copyArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> arr a -> Int -> Int -> m () Source #
copyMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> marr s a -> Int -> Int -> m () Source #
moveArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> marr s a -> Int -> Int -> m () Source #
cloneMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> Int -> m (marr s a) Source #
resizeMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> m (marr s a) Source #
shrinkMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s, HasCallStack) => marr s a -> Int -> m () Source #
New size should be >= 0, and <= original size.
No bound checked operations
unsafeFreezeArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s) => marr s a -> m (arr a) Source #
In place freeze a mutable array, the original mutable array can not be used anymore.
unsafeThawArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s) => arr a -> m (marr s a) Source #
In place thaw a immutable array, the original immutable array can not be used anymore.
sameMutableArr :: Arr marr arr a => marr s a -> marr s a -> Bool Source #
Is two mutable array are reference equal.
sizeofMutableArr :: (Arr marr arr a, PrimMonad m, PrimState m ~ s) => marr s a -> m Int Source #
Size of mutable array.
sameArr :: Arr marr arr a => 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.
Boxed array type
Instances
Monad Array | |
Functor Array | |
MonadFix 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 # 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 | |
Arr MutableArray Array a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MutableArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MutableArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MutableArray 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) => MutableArray s a -> Int -> Int -> m (Array a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> Int -> Int -> m (MutableArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> m (Array a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> m (MutableArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> Array a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> MutableArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> MutableArray s a -> Int -> Int -> m () Source # cloneArr :: Array a -> Int -> Int -> Array a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> Int -> m (MutableArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m (MutableArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m () Source # sameMutableArr :: MutableArray s a -> MutableArray s a -> Bool Source # sizeofArr :: Array a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> m Int 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 :: (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) | |
PrimUnlifted (Array a) | |
Defined in Data.Primitive.UnliftedArray toArrayArray# :: Array a -> ArrayArray# # fromArrayArray# :: ArrayArray# -> Array a # | |
type Item (Array a) | |
Defined in Data.Primitive.Array |
data MutableArray s a #
MutableArray | |
|
Instances
Arr MutableArray Array a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MutableArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MutableArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MutableArray 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) => MutableArray s a -> Int -> Int -> m (Array a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> Int -> Int -> m (MutableArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> m (Array a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => Array a -> m (MutableArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> Array a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> MutableArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> MutableArray s a -> Int -> Int -> m () Source # cloneArr :: Array a -> Int -> Int -> Array a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> Int -> m (MutableArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m (MutableArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> Int -> m () Source # sameMutableArr :: MutableArray s a -> MutableArray s a -> Bool Source # sizeofArr :: Array a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MutableArray s a -> m Int Source # | |
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 :: (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) # | |
PrimUnlifted (MutableArray s a) | |
Defined in Data.Primitive.UnliftedArray toArrayArray# :: MutableArray s a -> ArrayArray# # fromArrayArray# :: ArrayArray# -> MutableArray s a # |
data SmallArray a #
Instances
data SmallMutableArray s a #
Instances
Arr SmallMutableArray SmallArray a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (SmallMutableArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (SmallMutableArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray 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) => SmallMutableArray s a -> Int -> Int -> m (SmallArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => SmallArray a -> Int -> Int -> m (SmallMutableArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> m (SmallArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => SmallArray a -> m (SmallMutableArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> SmallArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> SmallMutableArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> SmallMutableArray s a -> Int -> Int -> m () Source # cloneArr :: SmallArray a -> Int -> Int -> SmallArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> Int -> m (SmallMutableArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> m (SmallMutableArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> Int -> m () Source # sameMutableArr :: SmallMutableArray s a -> SmallMutableArray s a -> Bool Source # sizeofArr :: SmallArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => SmallMutableArray s a -> m Int Source # sameArr :: SmallArray a -> SmallArray a -> Bool Source # | |
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 :: (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) # | |
PrimUnlifted (SmallMutableArray s a) | |
Defined in Data.Primitive.UnliftedArray toArrayArray# :: SmallMutableArray s a -> ArrayArray# # fromArrayArray# :: ArrayArray# -> SmallMutableArray s a # |
uninitialized :: a Source #
Bottom value (throw (
)
for initialize new boxed array(UndefinedElement
"Data.Array.uninitialized")Array
, SmallArray
..).
NOTE: These functions may segfault when used with indices which are out of bounds.
Primitive array type
Instances
data MutablePrimArray s a #
Instances
Prim a => Arr MutablePrimArray PrimArray a Source # | |
Defined in Std.Data.Array newArr :: (PrimMonad m, PrimState m ~ s) => Int -> m (MutablePrimArray s a) Source # newArrWith :: (PrimMonad m, PrimState m ~ s) => Int -> a -> m (MutablePrimArray s a) Source # readArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> m a Source # writeArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> a -> m () Source # setArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray 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) => MutablePrimArray s a -> Int -> Int -> m (PrimArray a) Source # thawArr :: (PrimMonad m, PrimState m ~ s) => PrimArray a -> Int -> Int -> m (MutablePrimArray s a) Source # unsafeFreezeArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> m (PrimArray a) Source # unsafeThawArr :: (PrimMonad m, PrimState m ~ s) => PrimArray a -> m (MutablePrimArray s a) Source # copyArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> PrimArray a -> Int -> Int -> m () Source # copyMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> MutablePrimArray s a -> Int -> Int -> m () Source # moveArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> MutablePrimArray s a -> Int -> Int -> m () Source # cloneArr :: PrimArray a -> Int -> Int -> PrimArray a Source # cloneMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> Int -> m (MutablePrimArray s a) Source # resizeMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> m (MutablePrimArray s a) Source # shrinkMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> Int -> m () Source # sameMutableArr :: MutablePrimArray s a -> MutablePrimArray s a -> Bool Source # sizeofArr :: PrimArray a -> Int Source # sizeofMutableArr :: (PrimMonad m, PrimState m ~ s) => MutablePrimArray s a -> m Int Source # | |
PrimUnlifted (MutablePrimArray s a) | |
Defined in Data.Primitive.UnliftedArray toArrayArray# :: MutablePrimArray s a -> ArrayArray# # fromArrayArray# :: ArrayArray# -> MutablePrimArray s a # |
Bound checked primitive array operations
newPinnedPrimArray :: (PrimMonad m, Prim a, HasCallStack) => Int -> m (MutablePrimArray (PrimState m) a) Source #
Create a pinned byte array of the specified size, The garbage collector is guaranteed not to move it.
newAlignedPinnedPrimArray :: (PrimMonad m, Prim a, HasCallStack) => Int -> m (MutablePrimArray (PrimState m) a) Source #
Create a pinned primitive array of the specified size and respect given primitive type's alignment. The garbage collector is guaranteed not to move it.
copyPrimArrayToPtr :: (PrimMonad m, Prim a, HasCallStack) => Ptr a -> PrimArray a -> Int -> Int -> m () Source #
copyMutablePrimArrayToPtr :: (PrimMonad m, Prim a, HasCallStack) => Ptr a -> MutablePrimArray (PrimState m) a -> Int -> Int -> m () Source #
copyPtrToMutablePrimArray :: (PrimMonad m, Prim a, HasCallStack) => MutablePrimArray (PrimState m) a -> Int -> Ptr a -> Int -> m () Source #
No bound checked primitive array operations
primArrayContents :: PrimArray a -> Ptr a Source #
Yield a pointer to the array's data.
This operation is only safe on pinned primitive arrays allocated by newPinnedPrimArray
or
newAlignedPinnedPrimArray
, and you have to make sure the PrimArray
can outlive the Ptr
.
mutablePrimArrayContents :: MutablePrimArray s a -> Ptr a Source #
Yield a pointer to the array's data.
This operation is only safe on pinned primitive arrays allocated by newPinnedPrimArray
or
newAlignedPinnedPrimArray
. and you have to make sure the PrimArray
can outlive the Ptr
.
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 Source #
Check if a primitive array is pinned.
isMutablePrimArrayPinned :: MutablePrimArray s a -> Bool Source #
Check if a mutable primitive array is pinned.
Unlifted array type
data UnliftedArray e #
Instances
data MutableUnliftedArray s e #
Instances
class PrimUnlifted a where #
toArrayArray# :: a -> ArrayArray# #
fromArrayArray# :: ArrayArray# -> a #
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 |