Z-Data-0.5.0.0: Array, vector and text
Copyright(c) Dong Han 2017
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.Data.Array

Description

Unified unboxed and boxed array operations using type family.

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:

Synopsis

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.

Associated Types

type MArr arr = (mar :: * -> * -> *) | mar -> arr Source #

Mutable version of this array type.

Methods

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.

copyArr Source #

Arguments

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

copyMutableArr Source #

Arguments

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

moveArr Source #

Arguments

:: (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 sameArr arr may return false if compiler decides to inline it.

See https://ghc.haskell.org/trac/ghc/ticket/13908 for more background.

Instances

Instances details
Prim a => Arr PrimArray a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr PrimArray = (mar :: Type -> Type -> Type) Source #

Methods

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 #

sameArr :: PrimArray a -> PrimArray a -> Bool Source #

Arr SmallArray a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr SmallArray = (mar :: Type -> Type -> Type) Source #

Methods

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 #

Arr Array a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr Array = (mar :: Type -> Type -> Type) Source #

Methods

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 #

sameArr :: Array a -> Array a -> Bool Source #

PrimUnlifted a => Arr (UnliftedArray :: Type -> Type) a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr UnliftedArray = (mar :: Type -> Type -> Type) Source #

Methods

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 #

data RealWorld #

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

data Array a #

Boxed arrays

Constructors

Array 

Fields

Instances

Instances details
Monad Array 
Instance details

Defined in Data.Primitive.Array

Methods

(>>=) :: Array a -> (a -> Array b) -> Array b #

(>>) :: Array a -> Array b -> Array b #

return :: a -> Array a #

Functor Array 
Instance details

Defined in Data.Primitive.Array

Methods

fmap :: (a -> b) -> Array a -> Array b #

(<$) :: a -> Array b -> Array a #

MonadFix Array 
Instance details

Defined in Data.Primitive.Array

Methods

mfix :: (a -> Array a) -> Array a #

MonadFail Array 
Instance details

Defined in Data.Primitive.Array

Methods

fail :: String -> Array a #

Applicative Array 
Instance details

Defined in Data.Primitive.Array

Methods

pure :: a -> Array a #

(<*>) :: Array (a -> b) -> Array a -> Array b #

liftA2 :: (a -> b -> c) -> Array a -> Array b -> Array c #

(*>) :: Array a -> Array b -> Array b #

(<*) :: Array a -> Array b -> Array a #

Foldable Array 
Instance details

Defined in Data.Primitive.Array

Methods

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 #

toList :: Array a -> [a] #

null :: Array a -> Bool #

length :: Array a -> Int #

elem :: Eq a => a -> Array a -> Bool #

maximum :: Ord a => Array a -> a #

minimum :: Ord a => Array a -> a #

sum :: Num a => Array a -> a #

product :: Num a => Array a -> a #

Traversable Array 
Instance details

Defined in Data.Primitive.Array

Methods

traverse :: Applicative f => (a -> f b) -> Array a -> f (Array b) #

sequenceA :: Applicative f => Array (f a) -> f (Array a) #

mapM :: Monad m => (a -> m b) -> Array a -> m (Array b) #

sequence :: Monad m => Array (m a) -> m (Array a) #

Eq1 Array

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.Array

Methods

liftEq :: (a -> b -> Bool) -> Array a -> Array b -> Bool #

Ord1 Array

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.Array

Methods

liftCompare :: (a -> b -> Ordering) -> Array a -> Array b -> Ordering #

Read1 Array

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.Array

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Array a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Array a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Array a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Array a] #

Show1 Array

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.Array

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Array a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Array a] -> ShowS #

MonadZip Array 
Instance details

Defined in Data.Primitive.Array

Methods

mzip :: Array a -> Array b -> Array (a, b) #

mzipWith :: (a -> b -> c) -> Array a -> Array b -> Array c #

munzip :: Array (a, b) -> (Array a, Array b) #

Alternative Array 
Instance details

Defined in Data.Primitive.Array

Methods

empty :: Array a #

(<|>) :: Array a -> Array a -> Array a #

some :: Array a -> Array [a] #

many :: Array a -> Array [a] #

MonadPlus Array 
Instance details

Defined in Data.Primitive.Array

Methods

mzero :: Array a #

mplus :: Array a -> Array a -> Array a #

NFData1 Array 
Instance details

Defined in Data.Primitive.Array

Methods

liftRnf :: (a -> ()) -> Array a -> () #

Arr Array a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr Array = (mar :: Type -> Type -> Type) Source #

Methods

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 #

sameArr :: Array a -> Array a -> Bool Source #

Vec Array a Source # 
Instance details

Defined in Z.Data.Vector.Base

Associated Types

type IArray Array :: Type -> Type Source #

Methods

toArr :: Array a -> (IArray Array a, Int, Int) Source #

fromArr :: IArray Array a -> Int -> Int -> Array a Source #

IsList (Array a) 
Instance details

Defined in Data.Primitive.Array

Associated Types

type Item (Array a) #

Methods

fromList :: [Item (Array a)] -> Array a #

fromListN :: Int -> [Item (Array a)] -> Array a #

toList :: Array a -> [Item (Array a)] #

Eq a => Eq (Array a) 
Instance details

Defined in Data.Primitive.Array

Methods

(==) :: Array a -> Array a -> Bool #

(/=) :: Array a -> Array a -> Bool #

Data a => Data (Array a) 
Instance details

Defined in Data.Primitive.Array

Methods

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)

Lexicographic ordering. Subject to change between major versions.

Instance details

Defined in Data.Primitive.Array

Methods

compare :: Array a -> Array a -> Ordering #

(<) :: Array a -> Array a -> Bool #

(<=) :: Array a -> Array a -> Bool #

(>) :: Array a -> Array a -> Bool #

(>=) :: Array a -> Array a -> Bool #

max :: Array a -> Array a -> Array a #

min :: Array a -> Array a -> Array a #

Read a => Read (Array a) 
Instance details

Defined in Data.Primitive.Array

Show a => Show (Array a) 
Instance details

Defined in Data.Primitive.Array

Methods

showsPrec :: Int -> Array a -> ShowS #

show :: Array a -> String #

showList :: [Array a] -> ShowS #

Semigroup (Array a)

Since: primitive-0.6.3.0

Instance details

Defined in Data.Primitive.Array

Methods

(<>) :: Array a -> Array a -> Array a #

sconcat :: NonEmpty (Array a) -> Array a #

stimes :: Integral b => b -> Array a -> Array a #

Monoid (Array a) 
Instance details

Defined in Data.Primitive.Array

Methods

mempty :: Array a #

mappend :: Array a -> Array a -> Array a #

mconcat :: [Array a] -> Array a #

NFData a => NFData (Array a) 
Instance details

Defined in Data.Primitive.Array

Methods

rnf :: Array a -> () #

Print a => Print (Array a) Source # 
Instance details

Defined in Z.Data.Text.Print

Methods

toUTF8BuilderP :: Int -> Array a -> Builder () Source #

JSON a => JSON (Array a) Source # 
Instance details

Defined in Z.Data.JSON.Base

type MArr Array Source # 
Instance details

Defined in Z.Data.Array

type IArray Array Source # 
Instance details

Defined in Z.Data.Vector.Base

type Item (Array a) 
Instance details

Defined in Data.Primitive.Array

type Item (Array a) = a

data MutableArray s a #

Mutable boxed arrays associated with a primitive state token.

Constructors

MutableArray 

Fields

Instances

Instances details
Eq (MutableArray s a) 
Instance details

Defined in Data.Primitive.Array

Methods

(==) :: MutableArray s a -> MutableArray s a -> Bool #

(/=) :: MutableArray s a -> MutableArray s a -> Bool #

(Typeable s, Typeable a) => Data (MutableArray s a) 
Instance details

Defined in Data.Primitive.Array

Methods

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 #

Constructors

SmallArray (SmallArray# a) 

Instances

Instances details
Monad SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

(>>=) :: SmallArray a -> (a -> SmallArray b) -> SmallArray b #

(>>) :: SmallArray a -> SmallArray b -> SmallArray b #

return :: a -> SmallArray a #

Functor SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

fmap :: (a -> b) -> SmallArray a -> SmallArray b #

(<$) :: a -> SmallArray b -> SmallArray a #

MonadFix SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

mfix :: (a -> SmallArray a) -> SmallArray a #

MonadFail SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

fail :: String -> SmallArray a #

Applicative SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

pure :: a -> SmallArray a #

(<*>) :: SmallArray (a -> b) -> SmallArray a -> SmallArray b #

liftA2 :: (a -> b -> c) -> SmallArray a -> SmallArray b -> SmallArray c #

(*>) :: SmallArray a -> SmallArray b -> SmallArray b #

(<*) :: SmallArray a -> SmallArray b -> SmallArray a #

Foldable SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

fold :: Monoid m => SmallArray m -> m #

foldMap :: Monoid m => (a -> m) -> SmallArray a -> m #

foldMap' :: Monoid m => (a -> m) -> SmallArray a -> m #

foldr :: (a -> b -> b) -> b -> SmallArray a -> b #

foldr' :: (a -> b -> b) -> b -> SmallArray a -> b #

foldl :: (b -> a -> b) -> b -> SmallArray a -> b #

foldl' :: (b -> a -> b) -> b -> SmallArray a -> b #

foldr1 :: (a -> a -> a) -> SmallArray a -> a #

foldl1 :: (a -> a -> a) -> SmallArray a -> a #

toList :: SmallArray a -> [a] #

null :: SmallArray a -> Bool #

length :: SmallArray a -> Int #

elem :: Eq a => a -> SmallArray a -> Bool #

maximum :: Ord a => SmallArray a -> a #

minimum :: Ord a => SmallArray a -> a #

sum :: Num a => SmallArray a -> a #

product :: Num a => SmallArray a -> a #

Traversable SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

traverse :: Applicative f => (a -> f b) -> SmallArray a -> f (SmallArray b) #

sequenceA :: Applicative f => SmallArray (f a) -> f (SmallArray a) #

mapM :: Monad m => (a -> m b) -> SmallArray a -> m (SmallArray b) #

sequence :: Monad m => SmallArray (m a) -> m (SmallArray a) #

Eq1 SmallArray

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.SmallArray

Methods

liftEq :: (a -> b -> Bool) -> SmallArray a -> SmallArray b -> Bool #

Ord1 SmallArray

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.SmallArray

Methods

liftCompare :: (a -> b -> Ordering) -> SmallArray a -> SmallArray b -> Ordering #

Read1 SmallArray

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.SmallArray

Show1 SmallArray

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.SmallArray

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> SmallArray a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [SmallArray a] -> ShowS #

MonadZip SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

mzip :: SmallArray a -> SmallArray b -> SmallArray (a, b) #

mzipWith :: (a -> b -> c) -> SmallArray a -> SmallArray b -> SmallArray c #

munzip :: SmallArray (a, b) -> (SmallArray a, SmallArray b) #

Alternative SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

MonadPlus SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

NFData1 SmallArray 
Instance details

Defined in Data.Primitive.SmallArray

Methods

liftRnf :: (a -> ()) -> SmallArray a -> () #

Arr SmallArray a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr SmallArray = (mar :: Type -> Type -> Type) Source #

Methods

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 #

Vec SmallArray a Source # 
Instance details

Defined in Z.Data.Vector.Base

Associated Types

type IArray SmallArray :: Type -> Type Source #

IsList (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

Associated Types

type Item (SmallArray a) #

Eq a => Eq (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

Methods

(==) :: SmallArray a -> SmallArray a -> Bool #

(/=) :: SmallArray a -> SmallArray a -> Bool #

Data a => Data (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SmallArray a -> c (SmallArray a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (SmallArray a) #

toConstr :: SmallArray a -> Constr #

dataTypeOf :: SmallArray a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (SmallArray a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (SmallArray a)) #

gmapT :: (forall b. Data b => b -> b) -> SmallArray a -> SmallArray a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SmallArray a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SmallArray a -> r #

gmapQ :: (forall d. Data d => d -> u) -> SmallArray a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SmallArray a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SmallArray a -> m (SmallArray a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SmallArray a -> m (SmallArray a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SmallArray a -> m (SmallArray a) #

Ord a => Ord (SmallArray a)

Lexicographic ordering. Subject to change between major versions.

Instance details

Defined in Data.Primitive.SmallArray

Read a => Read (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

Show a => Show (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

Semigroup (SmallArray a)

Since: primitive-0.6.3.0

Instance details

Defined in Data.Primitive.SmallArray

Monoid (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

NFData a => NFData (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

Methods

rnf :: SmallArray a -> () #

Print a => Print (SmallArray a) Source # 
Instance details

Defined in Z.Data.Text.Print

JSON a => JSON (SmallArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

type MArr SmallArray Source # 
Instance details

Defined in Z.Data.Array

type IArray SmallArray Source # 
Instance details

Defined in Z.Data.Vector.Base

type Item (SmallArray a) 
Instance details

Defined in Data.Primitive.SmallArray

type Item (SmallArray a) = a

data SmallMutableArray s a #

Instances

Instances details
Eq (SmallMutableArray s a) 
Instance details

Defined in Data.Primitive.SmallArray

(Typeable s, Typeable a) => Data (SmallMutableArray s a) 
Instance details

Defined in Data.Primitive.SmallArray

Methods

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 (UndefinedElement uninitialized)) for initialize new boxed array(Array, SmallArray..).

Primitive array type

data PrimArray a #

Arrays of unboxed elements. This accepts types like Double, Char, Int, and Word, as well as their fixed-length variants (Word8, Word16, etc.). Since the elements are unboxed, a PrimArray is strict in its elements. This differs from the behavior of Array, which is lazy in its elements.

Constructors

PrimArray ByteArray# 

Instances

Instances details
Prim a => Arr PrimArray a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr PrimArray = (mar :: Type -> Type -> Type) Source #

Methods

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 #

sameArr :: PrimArray a -> PrimArray a -> Bool Source #

Prim a => Vec PrimArray a Source # 
Instance details

Defined in Z.Data.Vector.Base

Associated Types

type IArray PrimArray :: Type -> Type Source #

Prim a => IsList (PrimArray a)

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.PrimArray

Associated Types

type Item (PrimArray a) #

Methods

fromList :: [Item (PrimArray a)] -> PrimArray a #

fromListN :: Int -> [Item (PrimArray a)] -> PrimArray a #

toList :: PrimArray a -> [Item (PrimArray a)] #

(Eq a, Prim a) => Eq (PrimArray a)

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.PrimArray

Methods

(==) :: PrimArray a -> PrimArray a -> Bool #

(/=) :: PrimArray a -> PrimArray a -> Bool #

(Ord a, Prim a) => Ord (PrimArray a)

Lexicographic ordering. Subject to change between major versions.

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.PrimArray

(Show a, Prim a) => Show (PrimArray a)

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.PrimArray

Semigroup (PrimArray a)

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.PrimArray

Methods

(<>) :: PrimArray a -> PrimArray a -> PrimArray a #

sconcat :: NonEmpty (PrimArray a) -> PrimArray a #

stimes :: Integral b => b -> PrimArray a -> PrimArray a #

Monoid (PrimArray a)

Since: primitive-0.6.4.0

Instance details

Defined in Data.Primitive.PrimArray

NFData (PrimArray a) 
Instance details

Defined in Data.Primitive.PrimArray

Methods

rnf :: PrimArray a -> () #

PrimUnlifted (PrimArray a) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

(Prim a, Print a) => Print (PrimArray a) Source # 
Instance details

Defined in Z.Data.Text.Print

(Prim a, JSON a) => JSON (PrimArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

type MArr PrimArray Source # 
Instance details

Defined in Z.Data.Array

type IArray PrimArray Source # 
Instance details

Defined in Z.Data.Vector.Base

type Item (PrimArray a) 
Instance details

Defined in Data.Primitive.PrimArray

type Item (PrimArray a) = a

data MutablePrimArray s a #

Mutable primitive arrays associated with a primitive state token. These can be written to and read from in a monadic context that supports sequencing such as IO or ST. Typically, a mutable primitive array will be built and then convert to an immutable primitive array using unsafeFreezePrimArray. However, it is also acceptable to simply discard a mutable primitive array since it lives in managed memory and will be garbage collected when no longer referenced.

Instances

Instances details
Eq (MutablePrimArray s a) 
Instance details

Defined in Data.Primitive.PrimArray

NFData (MutablePrimArray s a) 
Instance details

Defined in Data.Primitive.PrimArray

Methods

rnf :: MutablePrimArray s a -> () #

PrimUnlifted (MutablePrimArray s a) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

class Prim a where #

Class of types supporting primitive array operations. This includes interfacing with GC-managed memory (functions suffixed with ByteArray#) and interfacing with unmanaged memory (functions suffixed with Addr#). Endianness is platform-dependent.

Methods

sizeOf# :: a -> Int# #

Size of values of type a. The argument is not used.

alignment# :: a -> Int# #

Alignment of values of type a. The argument is not used.

indexByteArray# :: ByteArray# -> Int# -> a #

Read a value from the array. The offset is in elements of type a rather than in bytes.

readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, a #) #

Read a value from the mutable array. The offset is in elements of type a rather than in bytes.

writeByteArray# :: MutableByteArray# s -> Int# -> a -> State# s -> State# s #

Write a value to the mutable array. The offset is in elements of type a rather than in bytes.

setByteArray# :: MutableByteArray# s -> Int# -> Int# -> a -> State# s -> State# s #

Fill a slice of the mutable array with a value. The offset and length of the chunk are in elements of type a rather than in bytes.

indexOffAddr# :: Addr# -> Int# -> a #

Read a value from a memory position given by an address and an offset. The memory block the address refers to must be immutable. The offset is in elements of type a rather than in bytes.

readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, a #) #

Read a value from a memory position given by an address and an offset. The offset is in elements of type a rather than in bytes.

writeOffAddr# :: Addr# -> Int# -> a -> State# s -> State# s #

Write a value to a memory position given by an address and an offset. The offset is in elements of type a rather than in bytes.

setOffAddr# :: Addr# -> Int# -> Int# -> a -> State# s -> State# s #

Fill a memory block given by an address, an offset and a length. The offset and length are in elements of type a rather than in bytes.

Instances

Instances details
Prim Char 
Instance details

Defined in Data.Primitive.Types

Prim Double 
Instance details

Defined in Data.Primitive.Types

Prim Float 
Instance details

Defined in Data.Primitive.Types

Prim Int 
Instance details

Defined in Data.Primitive.Types

Prim Int8 
Instance details

Defined in Data.Primitive.Types

Prim Int16 
Instance details

Defined in Data.Primitive.Types

Prim Int32 
Instance details

Defined in Data.Primitive.Types

Prim Int64 
Instance details

Defined in Data.Primitive.Types

Prim Word 
Instance details

Defined in Data.Primitive.Types

Prim Word8 
Instance details

Defined in Data.Primitive.Types

Prim Word16 
Instance details

Defined in Data.Primitive.Types

Prim Word32 
Instance details

Defined in Data.Primitive.Types

Prim Word64 
Instance details

Defined in Data.Primitive.Types

Prim CDev 
Instance details

Defined in Data.Primitive.Types

Prim CIno 
Instance details

Defined in Data.Primitive.Types

Prim CMode 
Instance details

Defined in Data.Primitive.Types

Prim COff 
Instance details

Defined in Data.Primitive.Types

Prim CPid 
Instance details

Defined in Data.Primitive.Types

Prim CSsize 
Instance details

Defined in Data.Primitive.Types

Prim CGid 
Instance details

Defined in Data.Primitive.Types

Prim CNlink 
Instance details

Defined in Data.Primitive.Types

Prim CUid 
Instance details

Defined in Data.Primitive.Types

Prim CCc 
Instance details

Defined in Data.Primitive.Types

Prim CSpeed 
Instance details

Defined in Data.Primitive.Types

Prim CTcflag 
Instance details

Defined in Data.Primitive.Types

Prim CRLim 
Instance details

Defined in Data.Primitive.Types

Prim CBlkSize 
Instance details

Defined in Data.Primitive.Types

Prim CBlkCnt 
Instance details

Defined in Data.Primitive.Types

Prim CClockId 
Instance details

Defined in Data.Primitive.Types

Prim CFsBlkCnt 
Instance details

Defined in Data.Primitive.Types

Prim CFsFilCnt 
Instance details

Defined in Data.Primitive.Types

Prim CId 
Instance details

Defined in Data.Primitive.Types

Prim CKey 
Instance details

Defined in Data.Primitive.Types

Prim CTimer 
Instance details

Defined in Data.Primitive.Types

Prim Fd 
Instance details

Defined in Data.Primitive.Types

Prim CChar 
Instance details

Defined in Data.Primitive.Types

Prim CSChar 
Instance details

Defined in Data.Primitive.Types

Prim CUChar 
Instance details

Defined in Data.Primitive.Types

Prim CShort 
Instance details

Defined in Data.Primitive.Types

Prim CUShort 
Instance details

Defined in Data.Primitive.Types

Prim CInt 
Instance details

Defined in Data.Primitive.Types

Prim CUInt 
Instance details

Defined in Data.Primitive.Types

Prim CLong 
Instance details

Defined in Data.Primitive.Types

Prim CULong 
Instance details

Defined in Data.Primitive.Types

Prim CLLong 
Instance details

Defined in Data.Primitive.Types

Prim CULLong 
Instance details

Defined in Data.Primitive.Types

Prim CBool 
Instance details

Defined in Data.Primitive.Types

Prim CFloat 
Instance details

Defined in Data.Primitive.Types

Prim CDouble 
Instance details

Defined in Data.Primitive.Types

Prim CPtrdiff 
Instance details

Defined in Data.Primitive.Types

Prim CSize 
Instance details

Defined in Data.Primitive.Types

Prim CWchar 
Instance details

Defined in Data.Primitive.Types

Prim CSigAtomic 
Instance details

Defined in Data.Primitive.Types

Prim CClock 
Instance details

Defined in Data.Primitive.Types

Prim CTime 
Instance details

Defined in Data.Primitive.Types

Prim CUSeconds 
Instance details

Defined in Data.Primitive.Types

Prim CSUSeconds 
Instance details

Defined in Data.Primitive.Types

Prim CIntPtr 
Instance details

Defined in Data.Primitive.Types

Prim CUIntPtr 
Instance details

Defined in Data.Primitive.Types

Prim CIntMax 
Instance details

Defined in Data.Primitive.Types

Prim CUIntMax 
Instance details

Defined in Data.Primitive.Types

Prim WordPtr

Since: primitive-0.7.1.0

Instance details

Defined in Data.Primitive.Types

Prim IntPtr

Since: primitive-0.7.1.0

Instance details

Defined in Data.Primitive.Types

Prim (StablePtr a) 
Instance details

Defined in Data.Primitive.Types

Prim (Ptr a) 
Instance details

Defined in Data.Primitive.Types

Methods

sizeOf# :: Ptr a -> Int# #

alignment# :: Ptr a -> Int# #

indexByteArray# :: ByteArray# -> Int# -> Ptr a #

readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Ptr a #) #

writeByteArray# :: MutableByteArray# s -> Int# -> Ptr a -> State# s -> State# s #

setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Ptr a -> State# s -> State# s #

indexOffAddr# :: Addr# -> Int# -> Ptr a #

readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Ptr a #) #

writeOffAddr# :: Addr# -> Int# -> Ptr a -> State# s -> State# s #

setOffAddr# :: Addr# -> Int# -> Int# -> Ptr a -> State# s -> State# s #

Prim (FunPtr a) 
Instance details

Defined in Data.Primitive.Types

Prim a => Prim (Min a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Methods

sizeOf# :: Min a -> Int# #

alignment# :: Min a -> Int# #

indexByteArray# :: ByteArray# -> Int# -> Min a #

readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Min a #) #

writeByteArray# :: MutableByteArray# s -> Int# -> Min a -> State# s -> State# s #

setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Min a -> State# s -> State# s #

indexOffAddr# :: Addr# -> Int# -> Min a #

readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Min a #) #

writeOffAddr# :: Addr# -> Int# -> Min a -> State# s -> State# s #

setOffAddr# :: Addr# -> Int# -> Int# -> Min a -> State# s -> State# s #

Prim a => Prim (Max a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Methods

sizeOf# :: Max a -> Int# #

alignment# :: Max a -> Int# #

indexByteArray# :: ByteArray# -> Int# -> Max a #

readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Max a #) #

writeByteArray# :: MutableByteArray# s -> Int# -> Max a -> State# s -> State# s #

setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Max a -> State# s -> State# s #

indexOffAddr# :: Addr# -> Int# -> Max a #

readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Max a #) #

writeOffAddr# :: Addr# -> Int# -> Max a -> State# s -> State# s #

setOffAddr# :: Addr# -> Int# -> Int# -> Max a -> State# s -> State# s #

Prim a => Prim (First a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Prim a => Prim (Last a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Prim a => Prim (Identity a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Prim a => Prim (Dual a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Prim a => Prim (Sum a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Methods

sizeOf# :: Sum a -> Int# #

alignment# :: Sum a -> Int# #

indexByteArray# :: ByteArray# -> Int# -> Sum a #

readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Sum a #) #

writeByteArray# :: MutableByteArray# s -> Int# -> Sum a -> State# s -> State# s #

setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Sum a -> State# s -> State# s #

indexOffAddr# :: Addr# -> Int# -> Sum a #

readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Sum a #) #

writeOffAddr# :: Addr# -> Int# -> Sum a -> State# s -> State# s #

setOffAddr# :: Addr# -> Int# -> Int# -> Sum a -> State# s -> State# s #

Prim a => Prim (Product a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Prim a => Prim (Down a)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Prim a => Prim (RadixDown a) Source # 
Instance details

Defined in Z.Data.Vector.Sort

Prim a => Prim (Const a b)

Since: primitive-0.6.5.0

Instance details

Defined in Data.Primitive.Types

Methods

sizeOf# :: Const a b -> Int# #

alignment# :: Const a b -> Int# #

indexByteArray# :: ByteArray# -> Int# -> Const a b #

readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Const a b #) #

writeByteArray# :: MutableByteArray# s -> Int# -> Const a b -> State# s -> State# s #

setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Const a b -> State# s -> State# s #

indexOffAddr# :: Addr# -> Int# -> Const a b #

readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Const a b #) #

writeOffAddr# :: Addr# -> Int# -> Const a b -> State# s -> State# s #

setOffAddr# :: Addr# -> Int# -> Int# -> Const a b -> State# s -> State# s #

Array operations

newPinnedPrimArray :: (PrimMonad m, Prim a) => Int -> m (MutablePrimArray (PrimState m) a) #

Create a pinned primitive array of the specified size in elements. The garbage collector is guaranteed not to move it.

Since: primitive-0.7.1.0

newAlignedPinnedPrimArray :: (PrimMonad m, Prim a) => Int -> m (MutablePrimArray (PrimState m) a) #

Create a pinned primitive array of the specified size in elements and with the alignment given by its Prim instance. The garbage collector is guaranteed not to move it.

Since: primitive-0.7.0.0

copyPrimArrayToPtr #

Arguments

:: (PrimMonad m, Prim a) 
=> Ptr a

destination pointer

-> PrimArray a

source array

-> Int

offset into source array

-> Int

number of prims to copy

-> m () 

Copy a slice of an immutable primitive array to an address. The offset and length are given in elements of type a. This function assumes that the Prim instance of a agrees with the Storable instance. This function is only available when building with GHC 7.8 or newer.

Note: this function does not do bounds or overlap checking.

copyMutablePrimArrayToPtr #

Arguments

:: (PrimMonad m, Prim a) 
=> Ptr a

destination pointer

-> MutablePrimArray (PrimState m) a

source array

-> Int

offset into source array

-> Int

number of prims to copy

-> m () 

Copy a slice of an immutable primitive array to an address. The offset and length are given in elements of type a. This function assumes that the Prim instance of a agrees with the Storable instance. This function is only available when building with GHC 7.8 or newer.

Note: this function does not do bounds or overlap checking.

copyPtrToMutablePrimArray #

Arguments

:: (PrimMonad m, Prim a) 
=> MutablePrimArray (PrimState m) a

destination array

-> Int

destination offset

-> Ptr a

source pointer

-> Int

number of elements

-> m () 

Copy from a pointer to a mutable primitive array. The offset and length are given in elements of type a. This function is only available when building with GHC 7.8 or newer.

primArrayContents :: PrimArray a -> Ptr a #

Yield a pointer to the array's data. This operation is only safe on pinned prim arrays allocated by newPinnedByteArray or newAlignedPinnedByteArray.

Since: primitive-0.7.1.0

mutablePrimArrayContents :: MutablePrimArray s a -> Ptr a #

Yield a pointer to the array's data. This operation is only safe on pinned byte arrays allocated by newPinnedByteArray or newAlignedPinnedByteArray.

Since: primitive-0.7.1.0

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 #

Check whether or not the byte array is pinned. Pinned primitive arrays cannot be moved by the garbage collector. It is safe to use primArrayContents on such byte arrays. This function is only available when compiling with GHC 8.2 or newer.

Since: primitive-0.7.1.0

isMutablePrimArrayPinned :: MutablePrimArray s a -> Bool #

Check whether or not the mutable primitive array is pinned. This function is only available when compiling with GHC 8.2 or newer.

Since: primitive-0.7.1.0

Unlifted array type

data UnliftedArray a Source #

Array holding PrimUnlifted values.

Instances

Instances details
PrimUnlifted a => Arr (UnliftedArray :: Type -> Type) a Source # 
Instance details

Defined in Z.Data.Array

Associated Types

type MArr UnliftedArray = (mar :: Type -> Type -> Type) Source #

Methods

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 #

PrimUnlifted a => Vec (UnliftedArray :: Type -> Type) a Source # 
Instance details

Defined in Z.Data.Vector.Base

Associated Types

type IArray UnliftedArray :: Type -> Type Source #

(PrimUnlifted a, Print a) => Print (UnliftedArray a) Source # 
Instance details

Defined in Z.Data.Text.Print

(PrimUnlifted a, JSON a) => JSON (UnliftedArray a) Source # 
Instance details

Defined in Z.Data.JSON.Base

type MArr (UnliftedArray :: Type -> Type) Source # 
Instance details

Defined in Z.Data.Array

type IArray (UnliftedArray :: Type -> Type) Source # 
Instance details

Defined in Z.Data.Vector.Base

data MutableUnliftedArray s a Source #

Mutable array holding PrimUnlifted values.

class PrimUnlifted a where Source #

Types with TYPE UnliftedRep, which can be stored / retrieved in ArrayArray#.

Instances

Instances details
PrimUnlifted ByteArray Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

PrimUnlifted (IORef a) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

PrimUnlifted (MVar a) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

PrimUnlifted (PrimArray a) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

PrimUnlifted (MutableByteArray s) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

PrimUnlifted (STRef s a) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

PrimUnlifted (MutablePrimArray s a) Source # 
Instance details

Defined in Z.Data.Array.UnliftedArray

The ArrayException type

data ArrayException #

Exceptions generated by array operations

Constructors

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.

Cast between primitive arrays

class Cast source destination Source #

Cast between primitive types of the same size.

Minimal complete definition

cast

Instances

Instances details
Cast Double Int64 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Double -> Int64 Source #

Cast Double Word64 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Double -> Word64 Source #

Cast Float Int32 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Float -> Int32 Source #

Cast Float Word32 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Float -> Word32 Source #

Cast Int Word Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Int -> Word Source #

Cast Int8 Word8 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Int8 -> Word8 Source #

Cast Int16 Word16 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Int16 -> Word16 Source #

Cast Int32 Float Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Int32 -> Float Source #

Cast Int32 Word32 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Int32 -> Word32 Source #

Cast Int64 Double Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Int64 -> Double Source #

Cast Int64 Word64 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Int64 -> Word64 Source #

Cast Word Int Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Word -> Int Source #

Cast Word8 Int8 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Word8 -> Int8 Source #

Cast Word16 Int16 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Word16 -> Int16 Source #

Cast Word32 Float Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Word32 -> Float Source #

Cast Word32 Int32 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Word32 -> Int32 Source #

Cast Word64 Double Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Word64 -> Double Source #

Cast Word64 Int64 Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: Word64 -> Int64 Source #

Coercible a b => Cast a b Source # 
Instance details

Defined in Z.Data.Array.Cast

Methods

cast :: a -> b Source #

castArray :: (Arr arr a, Cast a b) => arr a -> arr b Source #

Cast between arrays

castMutableArray :: (Arr arr a, Cast a b) => MArr arr s a -> MArr arr s b Source #

Cast between mutable arrays

Re-export

sizeOf :: Prim a => a -> Int #

Size of values of type a. The argument is not used.

This function has existed since 0.1, but was moved from Primitive to Types in version 0.6.3.0