-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Unified interface for primitive arrays -- -- This package provides a typeclass Contiguous that offers a -- unified interface to working with Array, SmallArray, -- PrimArray, and UnliftedArray. @package contiguous @version 0.6.4.1 -- | The Contiguous typeclass parameterises over a contiguous array -- type. It provides the core primitives necessary to implement the -- common API in Data.Primitive.Contiguous. This allows us to have -- a common API to a number of contiguous array types and their mutable -- counterparts. module Data.Primitive.Contiguous.Class -- | The Contiguous typeclass as an interface to a multitude of -- contiguous structures. -- -- Some functions do not make sense on slices; for those, see -- ContiguousU. class Contiguous (arr :: Type -> Type) where { -- | The Mutable counterpart to the array. type Mutable arr = (r :: Type -> Type -> Type) | r -> arr; -- | The constraint needed to store elements in the array. type Element arr :: Type -> Constraint; -- | The slice type of this array. The slice of a raw array type t -- should be 'Slice t', whereas the slice of a slice should be the same -- slice type. type Sliced arr :: Type -> Type; -- | The mutable slice type of this array. The mutable slice of a raw array -- type t should be 'MutableSlice t', whereas the mutable slice -- of a mutable slice should be the same slice type. type MutableSliced arr :: Type -> Type -> Type; } -- | Allocate a new mutable array of the given size. new :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> m (Mutable arr (PrimState m) b) -- | replicateMut n x is a mutable array of length -- n with x the value of every element. replicateMut :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> b -> m (Mutable arr (PrimState m) b) -- | Resize an array without growing it. shrink :: (Contiguous arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (Mutable arr (PrimState m) a) -- | Resize an array without growing it. shrink :: (Contiguous arr, ContiguousU arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (Mutable arr (PrimState m) a) -- | The empty array. empty :: Contiguous arr => arr a -- | Create a singleton array. singleton :: (Contiguous arr, Element arr a) => a -> arr a -- | Create a doubleton array. doubleton :: (Contiguous arr, Element arr a) => a -> a -> arr a -- | Create a tripleton array. tripleton :: (Contiguous arr, Element arr a) => a -> a -> a -> arr a -- | Create a quadrupleton array. quadrupleton :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> arr a -- | Create a quintupleton array. quintupleton :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> a -> arr a -- | Create a sextupleton array. sextupleton :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> a -> a -> arr a -- | Index into an array at the given index. index :: (Contiguous arr, Element arr b) => arr b -> Int -> b -- | Index into an array at the given index, yielding an unboxed one-tuple -- of the element. index# :: (Contiguous arr, Element arr b) => arr b -> Int -> (# b #) -- | Indexing in a monad. -- -- The monad allows operations to be strict in the array when necessary. -- Suppose array copying is implemented like this: -- --
-- copy mv v = ... write mv i (v ! i) ... ---- -- For lazy arrays, v ! i would not be not be evaluated, which -- means that mv would unnecessarily retain a reference to -- v in each element written. -- -- With indexM, copying can be implemented like this instead: -- --
-- copy mv v = ... do -- x <- indexM v i -- write mv i x ---- -- Here, no references to v are retained because indexing (but -- not the elements) is evaluated eagerly. indexM :: (Contiguous arr, Element arr b, Monad m) => arr b -> Int -> m b -- | Read a mutable array at the given index. read :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m b -- | Write to a mutable array at the given index. write :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> b -> m () -- | Test whether the array is empty. null :: Contiguous arr => arr b -> Bool -- | The size of the array size :: (Contiguous arr, Element arr b) => arr b -> Int -- | The size of the mutable array sizeMut :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m Int -- | Test the two arrays for equality. equals :: (Contiguous arr, Element arr b, Eq b) => arr b -> arr b -> Bool -- | Test the two mutable arrays for pointer equality. Does not check -- equality of elements. equalsMut :: Contiguous arr => Mutable arr s a -> Mutable arr s a -> Bool -- | Create a Slice of an array. -- -- O(1). slice :: (Contiguous arr, Element arr a) => arr a -> Int -> Int -> Sliced arr a -- | Create a MutableSlice of a mutable array. -- -- O(1). sliceMut :: (Contiguous arr, Element arr a) => Mutable arr s a -> Int -> Int -> MutableSliced arr s a -- | Create a Slice that covers the entire array. toSlice :: (Contiguous arr, Element arr a) => arr a -> Sliced arr a -- | Create a MutableSlice that covers the entire array. toSliceMut :: (Contiguous arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> m (MutableSliced arr (PrimState m) a) -- | Clone a slice of an array. clone :: (Contiguous arr, Element arr b) => Sliced arr b -> arr b -- | Clone a slice of an array. clone :: (Contiguous arr, Sliced arr ~ Slice arr, ContiguousU arr, Element arr b) => Sliced arr b -> arr b -- | Clone a slice of an array without using the Slice type. These -- methods are required to implement 'Contiguous (Slice arr)' for any -- `Contiguous arr`; they are not really meant for direct use. clone_ :: (Contiguous arr, Element arr a) => arr a -> Int -> Int -> arr a -- | Clone a slice of a mutable array. cloneMut :: (Contiguous arr, PrimMonad m, Element arr b) => MutableSliced arr (PrimState m) b -> m (Mutable arr (PrimState m) b) -- | Clone a slice of a mutable array. cloneMut :: (Contiguous arr, MutableSliced arr ~ MutableSlice arr, ContiguousU arr, PrimMonad m, Element arr b) => MutableSliced arr (PrimState m) b -> m (Mutable arr (PrimState m) b) -- | Clone a slice of a mutable array without using the MutableSlice -- type. These methods are required to implement 'Contiguous (Slice arr)' -- for any `Contiguous arr`; they are not really meant for direct use. cloneMut_ :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Int -> m (Mutable arr (PrimState m) b) -- | Turn a mutable array slice an immutable array by copying. freeze :: (Contiguous arr, PrimMonad m, Element arr a) => MutableSliced arr (PrimState m) a -> m (arr a) -- | Turn a mutable array slice an immutable array by copying. freeze :: (Contiguous arr, MutableSliced arr ~ MutableSlice arr, ContiguousU arr, PrimMonad m, Element arr a) => MutableSliced arr (PrimState m) a -> m (arr a) -- | Turn a slice of a mutable array into an immutable one with copying, -- without using the MutableSlice type. These methods are required -- to implement 'Contiguous (Slice arr)' for any `Contiguous arr`; they -- are not really meant for direct use. freeze_ :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Int -> m (arr b) -- | Turn a mutable array into an immutable one without copying. The -- mutable array should not be used after this conversion. unsafeFreeze :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m (arr b) unsafeShrinkAndFreeze :: (Contiguous arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (arr a) unsafeShrinkAndFreeze :: (Contiguous arr, ContiguousU arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (arr a) -- | Copy a slice of an immutable array into a new mutable array. thaw :: (Contiguous arr, PrimMonad m, Element arr b) => Sliced arr b -> m (Mutable arr (PrimState m) b) -- | Copy a slice of an immutable array into a new mutable array. thaw :: (Contiguous arr, Sliced arr ~ Slice arr, ContiguousU arr, PrimMonad m, Element arr b) => Sliced arr b -> m (Mutable arr (PrimState m) b) -- | Copy a slice of an immutable array into a new mutable array without -- using the Slice type. These methods are required to implement -- 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really -- meant for direct use. thaw_ :: (Contiguous arr, PrimMonad m, Element arr b) => arr b -> Int -> Int -> m (Mutable arr (PrimState m) b) -- | Copy a slice of an array into a mutable array. copy :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Sliced arr b -> m () -- | Copy a slice of an array into a mutable array. copy :: (Contiguous arr, Sliced arr ~ Slice arr, ContiguousU arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Sliced arr b -> m () -- | Copy a slice of an array into a mutable array without using the -- Slice type. These methods are required to implement 'Contiguous -- (Slice arr)' for any `Contiguous arr`; they are not really meant for -- direct use. copy_ :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> arr b -> Int -> Int -> m () -- | Copy a slice of a mutable array into another mutable array. In the -- case that the destination and source arrays are the same, the regions -- may overlap. copyMut :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> MutableSliced arr (PrimState m) b -> m () -- | Copy a slice of a mutable array into another mutable array. In the -- case that the destination and source arrays are the same, the regions -- may overlap. copyMut :: (Contiguous arr, MutableSliced arr ~ MutableSlice arr, ContiguousU arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> MutableSliced arr (PrimState m) b -> m () -- | Copy a slice of a mutable array into another mutable array without -- using the Slice type. These methods are required to implement -- 'Contiguous (Slice arr)' for any `Contiguous arr`; they are not really -- meant for direct use. copyMut_ :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Mutable arr (PrimState m) b -> Int -> Int -> m () -- | Copy a slice of an array and then insert an element into that array. -- -- The default implementation performs a memset which would be -- unnecessary except that the garbage collector might trace the -- uninitialized array. -- -- Was previously insertSlicing @since 0.6.0 insertAt :: (Contiguous arr, Element arr b) => arr b -> Int -> b -> arr b -- | Copy a slice of an array and then insert an element into that array. -- -- The default implementation performs a memset which would be -- unnecessary except that the garbage collector might trace the -- uninitialized array. -- -- Was previously insertSlicing @since 0.6.0 insertAt :: (Contiguous arr, Element arr b, ContiguousU arr) => arr b -> Int -> b -> arr b -- | Reduce the array and all of its elements to WHNF. rnf :: (Contiguous arr, NFData a, Element arr a) => arr a -> () -- | Run an effectful computation that produces an array. run :: Contiguous arr => (forall s. ST s (arr a)) -> arr a -- | Slices of immutable arrays: packages an offset and length with a -- backing array. data Slice arr a Slice :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> !Unlifted arr a -> Slice arr a [offset] :: Slice arr a -> {-# UNPACK #-} !Int [length] :: Slice arr a -> {-# UNPACK #-} !Int [base] :: Slice arr a -> !Unlifted arr a -- | Slices of mutable arrays: packages an offset and length with a mutable -- backing array. data MutableSlice arr s a MutableSlice :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> !UnliftedMut arr s a -> MutableSlice arr s a [offsetMut] :: MutableSlice arr s a -> {-# UNPACK #-} !Int [lengthMut] :: MutableSlice arr s a -> {-# UNPACK #-} !Int [baseMut] :: MutableSlice arr s a -> !UnliftedMut arr s a -- | The ContiguousU typeclass is an extension of the -- Contiguous typeclass, but includes operations that make sense -- only on unsliced contiguous structures. class (Contiguous arr) => ContiguousU arr where { -- | The unifted version of the immutable array type (i.e. eliminates an -- indirection through a thunk). type Unlifted arr = (r :: Type -> TYPE UnliftedRep) | r -> arr; -- | The unifted version of the mutable array type (i.e. eliminates an -- indirection through a thunk). type UnliftedMut arr = (r :: Type -> Type -> TYPE UnliftedRep) | r -> arr; } -- | Resize an array into one with the given size. resize :: (ContiguousU arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m (Mutable arr (PrimState m) b) -- | Unlift an array (i.e. point to the data without an intervening thunk). unlift :: ContiguousU arr => arr b -> Unlifted arr b -- | Unlift a mutable array (i.e. point to the data without an intervening -- thunk). unliftMut :: ContiguousU arr => Mutable arr s b -> UnliftedMut arr s b -- | Lift an array (i.e. point to the data through an intervening thunk). lift :: ContiguousU arr => Unlifted arr b -> arr b -- | Lift a mutable array (i.e. point to the data through an intervening -- thunk). liftMut :: ContiguousU arr => UnliftedMut arr s b -> Mutable arr s b -- | A typeclass that is satisfied by all types. This is used used to -- provide a fake constraint for Array and SmallArray. class Always a instance Data.Primitive.Contiguous.Class.ContiguousU (Data.Primitive.Unlifted.Array.ST.UnliftedArray_ unlifted_a) instance (Data.Primitive.Unlifted.Class.Unlifted a GHC.Types.~ u, Data.Primitive.Unlifted.Class.PrimUnlifted a) => Data.Primitive.Contiguous.Class.PrimUnliftsInto u a instance Data.Primitive.Contiguous.Class.Contiguous (Data.Primitive.Unlifted.Array.ST.UnliftedArray_ unlifted_a) instance Data.Primitive.Contiguous.Class.ContiguousU Data.Primitive.PrimArray.PrimArray instance Data.Primitive.Contiguous.Class.Always a instance Data.Primitive.Contiguous.Class.Contiguous Data.Primitive.SmallArray.SmallArray instance Data.Primitive.Contiguous.Class.Contiguous Data.Primitive.Array.Array instance Data.Primitive.Contiguous.Class.ContiguousU arr => Data.Primitive.Contiguous.Class.Contiguous (Data.Primitive.Contiguous.Class.Slice arr) instance Data.Primitive.Contiguous.Class.ContiguousU Data.Primitive.SmallArray.SmallArray instance Data.Primitive.Contiguous.Class.Contiguous Data.Primitive.PrimArray.PrimArray instance Data.Primitive.Contiguous.Class.ContiguousU Data.Primitive.Array.Array -- | The contiguous package presents a common API to a number of contiguous -- array types and their mutable counterparts. This is enabled with the -- Contiguous typeclass, which parameterises over a contiguous -- array type and defines the core operations. However, the stable part -- of the interface is contained in this module, which combines those -- primitives into common, efficient array algorithms suitable for -- replacing pointer-heavy list manipulations. module Data.Primitive.Contiguous -- | The size of the array size :: (Contiguous arr, Element arr b) => arr b -> Int -- | The size of the mutable array sizeMut :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m Int -- | Test whether the array is empty. null :: Contiguous arr => arr b -> Bool -- | Index into an array at the given index. index :: (Contiguous arr, Element arr b) => arr b -> Int -> b -- | Index into an array at the given index, yielding an unboxed one-tuple -- of the element. index# :: (Contiguous arr, Element arr b) => arr b -> Int -> (# b #) -- | Read a mutable array at the given index. read :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m b -- | Indexing in a monad. -- -- The monad allows operations to be strict in the array when necessary. -- Suppose array copying is implemented like this: -- --
-- copy mv v = ... write mv i (v ! i) ... ---- -- For lazy arrays, v ! i would not be not be evaluated, which -- means that mv would unnecessarily retain a reference to -- v in each element written. -- -- With indexM, copying can be implemented like this instead: -- --
-- copy mv v = ... do -- x <- indexM v i -- write mv i x ---- -- Here, no references to v are retained because indexing (but -- not the elements) is evaluated eagerly. indexM :: (Contiguous arr, Element arr b, Monad m) => arr b -> Int -> m b -- | The empty array. empty :: Contiguous arr => arr a -- | Allocate a new mutable array of the given size. new :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> m (Mutable arr (PrimState m) b) -- | Create a singleton array. singleton :: (Contiguous arr, Element arr a) => a -> arr a -- | Create a doubleton array. doubleton :: (Contiguous arr, Element arr a) => a -> a -> arr a -- | Create a tripleton array. tripleton :: (Contiguous arr, Element arr a) => a -> a -> a -> arr a -- | Create a quadrupleton array. quadrupleton :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> arr a -- | Create a quintupleton array. quintupleton :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> a -> arr a -- | Create a sextupleton array. sextupleton :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> a -> a -> arr a -- | replicate n x is an array of length n with -- x the value of every element. replicate :: (Contiguous arr, Element arr a) => Int -> a -> arr a -- | replicateMut n x is a mutable array of length -- n with x the value of every element. replicateMut :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> b -> m (Mutable arr (PrimState m) b) -- | Construct an array of the given length by applying the function to -- each index. generate :: (Contiguous arr, Element arr a) => Int -> (Int -> a) -> arr a -- | Construct an array of the given length by applying the monadic action -- to each index. generateM :: (Contiguous arr, Element arr a, Monad m) => Int -> (Int -> m a) -> m (arr a) -- | Construct a mutable array of the given length by applying the function -- to each index. generateMutable :: (Contiguous arr, Element arr a, PrimMonad m) => Int -> (Int -> a) -> m (Mutable arr (PrimState m) a) -- | Apply a function n times to a value and construct an array -- where each consecutive element is the result of an additional -- application of this function. The zeroth element is the original -- value. -- --
-- iterateN 5 (+ 1) 0 = fromListN 5 [0,1,2,3,4] --iterateN :: (Contiguous arr, Element arr a) => Int -> (a -> a) -> a -> arr a -- | Apply a function n times to a value and construct a mutable -- array where each consecutive element is the result of an additional -- application of this function. The zeroth element is the original -- value. iterateMutableN :: (Contiguous arr, Element arr a, PrimMonad m) => Int -> (a -> a) -> a -> m (Mutable arr (PrimState m) a) -- | Write to a mutable array at the given index. write :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> b -> m () construct1 :: (Contiguous arr, Element arr a) => a -> arr a construct2 :: (Contiguous arr, Element arr a) => a -> a -> arr a construct3 :: (Contiguous arr, Element arr a) => a -> a -> a -> arr a construct4 :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> arr a construct5 :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> a -> arr a construct6 :: (Contiguous arr, Element arr a) => a -> a -> a -> a -> a -> a -> arr a -- | Run an effectful computation that produces an array. run :: Contiguous arr => (forall s. ST s (arr a)) -> arr a -- | replicateMutM n act performs the action n times, -- gathering the results. replicateMutM :: (PrimMonad m, Contiguous arr, Element arr a) => Int -> m a -> m (Mutable arr (PrimState m) a) -- | Construct a mutable array of the given length by applying the monadic -- action to each index. generateMutableM :: (Contiguous arr, Element arr a, PrimMonad m) => Int -> (Int -> m a) -> m (Mutable arr (PrimState m) a) -- | Apply a monadic function n times to a value and construct a -- mutable array where each consecutive element is the result of an -- additional application of this function. The zeroth element is the -- original value. iterateMutableNM :: (Contiguous arr, Element arr a, PrimMonad m) => Int -> (a -> m a) -> a -> m (Mutable arr (PrimState m) a) -- | Execute the monad action and freeze the resulting array. create :: (Contiguous arr, Element arr a) => (forall s. ST s (Mutable arr s a)) -> arr a -- | Execute the monadic action and freeze the resulting array. createT :: (Contiguous arr, Element arr a, Traversable f) => (forall s. ST s (f (Mutable arr s a))) -> f (arr a) -- | Construct an array by repeatedly applying a generator function to a -- seed. The generator function yields Just the next element and -- the new seed or Nothing if there are no more elements. -- --
-- >>> unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1) 10 -- <10,9,8,7,6,5,4,3,2,1> --unfoldr :: (Contiguous arr, Element arr a) => (b -> Maybe (a, b)) -> b -> arr a -- | Construct an array with at most n elements by repeatedly applying the -- generator function to a seed. The generator function yields -- Just the next element and the new seed or Nothing if -- there are no more elements. unfoldrN :: (Contiguous arr, Element arr a) => Int -> (b -> Maybe (a, b)) -> b -> arr a -- | Construct a mutable array by repeatedly applying a generator function -- to a seed. The generator function yields Just the next element -- and the new seed or Nothing if there are no more elements. -- --
-- >>> unfoldrMutable (\n -> if n == 0 then Nothing else Just (n,n-1) 10 -- <10,9,8,7,6,5,4,3,2,1> --unfoldrMutable :: (Contiguous arr, Element arr a, PrimMonad m) => (b -> Maybe (a, b)) -> b -> m (Mutable arr (PrimState m) a) -- | Yield an array of the given length containing the values x, -- succ x, succ (succ x) etc. enumFromN :: (Contiguous arr, Element arr a, Enum a) => a -> Int -> arr a -- | Yield a mutable array of the given length containing the values x, -- succ x, succ (succ x) etc. enumFromMutableN :: (Contiguous arr, Element arr a, PrimMonad m, Enum a) => a -> Int -> m (Mutable arr (PrimState m) a) -- | Append two arrays. append :: (Contiguous arr, Element arr a) => arr a -> arr a -> arr a -- | Copy a slice of an array and then insert an element into that array. -- -- The default implementation performs a memset which would be -- unnecessary except that the garbage collector might trace the -- uninitialized array. -- -- Was previously insertSlicing @since 0.6.0 insertAt :: (Contiguous arr, Element arr b) => arr b -> Int -> b -> arr b -- | Slices of immutable arrays: packages an offset and length with a -- backing array. data Slice arr a -- | Slices of mutable arrays: packages an offset and length with a mutable -- backing array. data MutableSlice arr s a -- | Create a Slice of an array. -- -- O(1). slice :: (Contiguous arr, Element arr a) => arr a -> Int -> Int -> Sliced arr a -- | Create a MutableSlice of a mutable array. -- -- O(1). sliceMut :: (Contiguous arr, Element arr a) => Mutable arr s a -> Int -> Int -> MutableSliced arr s a -- | Create a Slice that covers the entire array. toSlice :: (Contiguous arr, Element arr a) => arr a -> Sliced arr a -- | Create a MutableSlice that covers the entire array. toSliceMut :: (Contiguous arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> m (MutableSliced arr (PrimState m) a) -- | Create a copy of an array except the element at the index is replaced -- with the given value. replaceAt :: (Contiguous arr, Element arr a) => arr a -> Int -> a -> arr a modifyAt :: (Contiguous arr, Element arr a) => (a -> a) -> arr a -> Int -> arr a -- | Variant of modifyAt that forces the result before installing it in the -- array. modifyAt' :: (Contiguous arr, Element arr a) => (a -> a) -> arr a -> Int -> arr a modifyAtF :: (Contiguous arr, Element arr a, Functor f) => (a -> f a) -> arr a -> Int -> f (arr a) -- | Variant of modifyAtF that forces the result before installing it in -- the array. Note that this requires Monad rather than -- Functor. modifyAtF' :: (Contiguous arr, Element arr a, Monad f) => (a -> f a) -> arr a -> Int -> f (arr a) -- | Delete the element at the given position. deleteAt :: (Contiguous arr, Element arr a) => arr a -> Int -> arr a -- | Reverse the elements of an array. reverse :: (Contiguous arr, Element arr a) => arr a -> arr a -- | Reverse the elements of a mutable array, in-place. reverseMutable :: (Contiguous arr, Element arr a, PrimMonad m) => Mutable arr (PrimState m) a -> m () -- | Reverse the elements of a slice of a mutable array, in-place. reverseSlice :: (Contiguous arr, Element arr a, PrimMonad m) => Mutable arr (PrimState m) a -> Int -> Int -> m () -- | Resize an array into one with the given size. resize :: (ContiguousU arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m (Mutable arr (PrimState m) b) -- | Resize an array without growing it. shrink :: (Contiguous arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (Mutable arr (PrimState m) a) unsafeShrinkAndFreeze :: (Contiguous arr, PrimMonad m, Element arr a) => Mutable arr (PrimState m) a -> Int -> m (arr a) -- | Map over the elements of an array. -- -- Note that because a new array must be created, the resulting array -- type can be different than the original. map :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c -- | Map strictly over the elements of an array. -- -- Note that because a new array must be created, the resulting array -- type can be different than the original. map' :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c -- | Map over a mutable array, modifying the elements in place. mapMutable :: (Contiguous arr, Element arr a, PrimMonad m) => (a -> a) -> Mutable arr (PrimState m) a -> m () -- | Strictly map over a mutable array, modifying the elements in place. mapMutable' :: (PrimMonad m, Contiguous arr, Element arr a) => (a -> a) -> Mutable arr (PrimState m) a -> m () -- | Map over the elements of an array with the index. imap :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (Int -> b -> c) -> arr1 b -> arr2 c -- | Map strictly over the elements of an array with the index. -- -- Note that because a new array must be created, the resulting array -- type can be different than the original. imap' :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (Int -> b -> c) -> arr1 b -> arr2 c -- | Map over a mutable array with indices, modifying the elements in -- place. imapMutable :: (Contiguous arr, Element arr a, PrimMonad m) => (Int -> a -> a) -> Mutable arr (PrimState m) a -> m () -- | Strictly map over a mutable array with indices, modifying the elements -- in place. imapMutable' :: (PrimMonad m, Contiguous arr, Element arr a) => (Int -> a -> a) -> Mutable arr (PrimState m) a -> m () -- | Modify the elements of a mutable array in-place. modify :: (Contiguous arr, Element arr a, PrimMonad m) => (a -> a) -> Mutable arr (PrimState m) a -> m () -- | Strictly modify the elements of a mutable array in-place. modify' :: (Contiguous arr, Element arr a, PrimMonad m) => (a -> a) -> Mutable arr (PrimState m) a -> m () -- | The mapMaybe function is a version of map which can -- throw out elements. In particular, the functional arguments returns -- something of type Maybe b. If this is Nothing, -- no element is added on to the result array. If it is Just -- b, then b is included in the result array. mapMaybe :: forall arr1 arr2 a b. (Contiguous arr1, Element arr1 a, Contiguous arr2, Element arr2 b) => (a -> Maybe b) -> arr1 a -> arr2 b -- | zip takes two arrays and returns an array of corresponding -- pairs. -- --
-- zip [1, 2] ['a', 'b'] = [(1, 'a'), (2, 'b')] ---- -- If one input array is shorter than the other, excess elements of the -- longer array are discarded: -- --
-- zip [1] ['a', 'b'] = [(1, 'a')] -- zip [1, 2] ['a'] = [(1, 'a')] --zip :: (Contiguous arr1, Contiguous arr2, Contiguous arr3, Element arr1 a, Element arr2 b, Element arr3 (a, b)) => arr1 a -> arr2 b -> arr3 (a, b) -- | zipWith generalises zip by zipping with the function -- given as the first argument, instead of a tupling function. For -- example, zipWith (+) is applied to two arrays to produce an -- array of the corresponding sums. zipWith :: (Contiguous arr1, Contiguous arr2, Contiguous arr3, Element arr1 a, Element arr2 b, Element arr3 c) => (a -> b -> c) -> arr1 a -> arr2 b -> arr3 c -- | Variant of zipWith that provides the index of each pair of -- elements. izipWith :: (Contiguous arr1, Contiguous arr2, Contiguous arr3, Element arr1 a, Element arr2 b, Element arr3 c) => (Int -> a -> b -> c) -> arr1 a -> arr2 b -> arr3 c -- | Swap the elements of the mutable array at the given indices. swap :: (Contiguous arr, Element arr a, PrimMonad m) => Mutable arr (PrimState m) a -> Int -> Int -> m () -- | Drop elements that do not satisfy the predicate. filter :: (Contiguous arr, Element arr a) => (a -> Bool) -> arr a -> arr a -- | Drop elements that do not satisfy the predicate which is applied to -- values and their indices. ifilter :: (Contiguous arr, Element arr a) => (Int -> a -> Bool) -> arr a -> arr a -- | The catMaybes function takes a list of Maybes and -- returns a list of all the Just values. catMaybes :: (Contiguous arr, Element arr a, Element arr (Maybe a)) => arr (Maybe a) -> arr a -- | Extracts from an array of Either all the Left elements. -- All the Left elements are extracted in order. lefts :: forall arr a b. (Contiguous arr, Element arr a, Element arr (Either a b)) => arr (Either a b) -> arr a -- | Extracts from an array of Either all the Right elements. -- All the Right elements are extracted in order. rights :: forall arr a b. (Contiguous arr, Element arr b, Element arr (Either a b)) => arr (Either a b) -> arr b -- | Partitions an array of Either into two arrays. All the -- Left elements are extracted, in order, to the first component -- of the output. Similarly the Right elements are extracted to -- the second component of the output. partitionEithers :: forall arr a b. (Contiguous arr, Element arr a, Element arr b, Element arr (Either a b)) => arr (Either a b) -> (arr a, arr b) -- | find takes a predicate and an array, and returns the leftmost -- element of the array matching the prediate, or Nothing if there -- is no such element. find :: (Contiguous arr, Element arr a) => (a -> Bool) -> arr a -> Maybe a -- | findIndex takes a predicate and an array, and returns the index -- of the leftmost element of the array matching the prediate, or -- Nothing if there is no such element. findIndex :: (Contiguous arr, Element arr a) => (a -> Bool) -> arr a -> Maybe Int -- | Does the element occur in the structure? elem :: (Contiguous arr, Element arr a, Eq a) => a -> arr a -> Bool -- | The largest element of a structure. maximum :: (Contiguous arr, Element arr a, Ord a) => arr a -> Maybe a -- | The least element of a structure. minimum :: (Contiguous arr, Element arr a, Ord a) => arr a -> Maybe a -- | The largest element of a structure with respect to the given -- comparison function. maximumBy :: (Contiguous arr, Element arr a) => (a -> a -> Ordering) -> arr a -> Maybe a -- | The least element of a structure with respect to the given comparison -- function. minimumBy :: (Contiguous arr, Element arr a) => (a -> a -> Ordering) -> arr a -> Maybe a -- | Test the two arrays for equality. equals :: (Contiguous arr, Element arr b, Eq b) => arr b -> arr b -> Bool -- | Test the two mutable arrays for pointer equality. Does not check -- equality of elements. equalsMut :: Contiguous arr => Mutable arr s a -> Mutable arr s a -> Bool -- | This function does not behave deterministically. Optimization level -- and inlining can affect its results. However, the one thing that can -- be counted on is that if it returns True, the two immutable -- arrays are definitely the same. This is useful as shortcut for -- equality tests. However, keep in mind that a result of False -- tells us nothing about the arguments. same :: ContiguousU arr => arr a -> arr a -> Bool -- | Left fold over the elements of an array. foldl :: (Contiguous arr, Element arr a) => (b -> a -> b) -> b -> arr a -> b -- | Strict left fold over the elements of an array. foldl' :: (Contiguous arr, Element arr a) => (b -> a -> b) -> b -> arr a -> b -- | Right fold over the element of an array. foldr :: (Contiguous arr, Element arr a) => (a -> b -> b) -> b -> arr a -> b -- | Strict right fold over the elements of an array. foldr' :: (Contiguous arr, Element arr a) => (a -> b -> b) -> b -> arr a -> b -- | Monoidal fold over the element of an array. foldMap :: (Contiguous arr, Element arr a, Monoid m) => (a -> m) -> arr a -> m -- | Strict monoidal fold over the elements of an array. foldMap' :: (Contiguous arr, Element arr a, Monoid m) => (a -> m) -> arr a -> m -- | Strict left monoidal fold over the elements of an array. foldlMap' :: (Contiguous arr, Element arr a, Monoid m) => (a -> m) -> arr a -> m -- | Strict left fold over the elements of an array, where the accumulating -- function cares about the index of the element. ifoldl' :: (Contiguous arr, Element arr a) => (b -> Int -> a -> b) -> b -> arr a -> b -- | Right fold over the element of an array, lazy in the accumulator, -- provides index to the step function. ifoldr :: (Contiguous arr, Element arr a) => (Int -> a -> b -> b) -> b -> arr a -> b -- | Strict right fold over the elements of an array, where the -- accumulating function cares about the index of the element. ifoldr' :: (Contiguous arr, Element arr a) => (Int -> a -> b -> b) -> b -> arr a -> b -- | Strict monoidal fold over the elements of an array. ifoldlMap' :: (Contiguous arr, Element arr a, Monoid m) => (Int -> a -> m) -> arr a -> m -- | Strict monoidal fold over the elements of an array. ifoldlMap1' :: (Contiguous arr, Element arr a, Semigroup m) => (Int -> a -> m) -> arr a -> m -- | Strict left monadic fold over the elements of an array. foldlM' :: (Contiguous arr, Element arr a, Monad m) => (b -> a -> m b) -> b -> arr a -> m b -- | Strict left monadic fold over the elements of an array. ifoldlM' :: (Contiguous arr, Element arr a, Monad m) => (b -> Int -> a -> m b) -> b -> arr a -> m b -- | Strict right monadic fold over the elements of an array. foldrM' :: (Contiguous arr, Element arr a, Monad m) => (a -> b -> m b) -> b -> arr a -> m b -- | The sum of a collection of actions, generalizing concat. -- --
-- >>> asum (C.fromList ['Just' "Hello", 'Nothing', Just "World"] :: Array String) -- Just "Hello" --asum :: (Contiguous arr, Element arr (f a), Alternative f) => arr (f a) -> f a all :: (Contiguous arr, Element arr a) => (a -> Bool) -> arr a -> Bool any :: (Contiguous arr, Element arr a) => (a -> Bool) -> arr a -> Bool -- | Variant of zipWith that accepts an accumulator, performing a -- lazy right fold over both arrays. foldrZipWith :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (a -> b -> c -> c) -> c -> arr1 a -> arr2 b -> c -- | Variant of foldrZipWith that provides the index of each pair of -- elements. ifoldrZipWith :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (Int -> a -> b -> c -> c) -> c -> arr1 a -> arr2 b -> c foldlZipWith' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (c -> a -> b -> c) -> c -> arr1 a -> arr2 b -> c ifoldlZipWith' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (Int -> c -> a -> b -> c) -> c -> arr1 a -> arr2 b -> c -- | Variant of zipWith that accepts an accumulator, performing a -- strict left monadic fold over both arrays. foldlZipWithM' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b, Monad m) => (c -> a -> b -> m c) -> c -> arr1 a -> arr2 b -> m c -- | Variant of 'foldlZipWithM'' that provides the index of each pair of -- elements. ifoldlZipWithM' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b, Monad m) => (Int -> c -> a -> b -> m c) -> c -> arr1 a -> arr2 b -> m c -- | Map each element of the array to an action, evaluate these actions -- from left to right, and collect the results. For a version that -- ignores the results, see traverse_. traverse :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b, Applicative f) => (a -> f b) -> arr1 a -> f (arr2 b) -- | Map each element of the array to an action, evaluate these actions -- from left to right, and ignore the results. For a version that doesn't -- ignore the results, see traverse. traverse_ :: (Contiguous arr, Element arr a, Applicative f) => (a -> f b) -> arr a -> f () -- | Map each element of the array and its index to an action, evaluating -- these actions from left to right. itraverse :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b, Applicative f) => (Int -> a -> f b) -> arr1 a -> f (arr2 b) -- | Map each element of the array and its index to an action, evaluate -- these actions from left to right, and ignore the results. For a -- version that doesn't ignore the results, see itraverse. itraverse_ :: (Contiguous arr, Element arr a, Applicative f) => (Int -> a -> f b) -> arr a -> f () -- | Map each element of the array to an action, evaluate these actions -- from left to right, and collect the results in a new array. traverseP :: (PrimMonad m, Contiguous arr1, Element arr1 a, Contiguous arr2, Element arr2 b) => (a -> m b) -> arr1 a -> m (arr2 b) -- | Map each element of the array to an action, evaluate these actions -- from left to right, and collect the results in a new array. itraverseP :: (PrimMonad m, Contiguous arr1, Element arr1 a, Contiguous arr2, Element arr2 b) => (Int -> a -> m b) -> arr1 a -> m (arr2 b) -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and collect the results. for a version -- that ignores the results see mapM_. mapM :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b, Monad m) => (a -> m b) -> arr1 a -> m (arr2 b) -- | forM is mapM with its arguments flipped. For a version -- that ignores its results, see forM_. forM :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b, Monad m) => arr1 a -> (a -> m b) -> m (arr2 b) -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and ignore the results. For a version that -- doesn't ignore the results see mapM. -- -- mapM_ = traverse_ mapM_ :: (Contiguous arr, Element arr a, Element arr b, Applicative f) => (a -> f b) -> arr a -> f () -- | forM_ is mapM_ with its arguments flipped. For a version -- that doesn't ignore its results, see forM. forM_ :: (Contiguous arr, Element arr a, Element arr b, Applicative f) => arr a -> (a -> f b) -> f () -- | for is traverse with its arguments flipped. For a -- version that ignores the results see for_. for :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b, Applicative f) => arr1 a -> (a -> f b) -> f (arr2 b) -- | for_ is traverse_ with its arguments flipped. For a -- version that doesn't ignore the results see for. -- --
-- >>> for_ (C.fromList [1..4] :: PrimArray Int) print -- 1 -- 2 -- 3 -- 4 --for_ :: (Contiguous arr, Element arr a, Applicative f) => arr a -> (a -> f b) -> f () -- | Evaluate each action in the structure from left to right and collect -- the results. For a version that ignores the results see -- sequence_. sequence :: (Contiguous arr1, Contiguous arr2, Element arr1 (f a), Element arr2 a, Applicative f) => arr1 (f a) -> f (arr2 a) -- | Evaluate each action in the structure from left to right and ignore -- the results. For a version that doesn't ignore the results see -- sequence. sequence_ :: (Contiguous arr, Element arr (f a), Applicative f) => arr (f a) -> f () -- | Replace all locations in the input with the same value. -- -- Equivalent to Data.Functor.<$. (<$) :: (Contiguous arr1, Contiguous arr2, Element arr1 b, Element arr2 a) => a -> arr1 b -> arr2 a -- | Sequential application. -- -- Equivalent to Control.Applicative.<*>. ap :: (Contiguous arr1, Contiguous arr2, Contiguous arr3, Element arr1 (a -> b), Element arr2 a, Element arr3 b) => arr1 (a -> b) -> arr2 a -> arr3 b -- | scanl is similar to foldl, but returns an array of -- successive reduced values from the left: -- --
-- scanl f z [x1, x2, ...] = [z, f z x1, f (f z x1) x2, ...] ---- -- Note that -- --
-- last (toList (scanl f z xs)) == foldl f z xs. --scanl :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (b -> a -> b) -> b -> arr1 a -> arr2 b -- | A strictly accumulating version of scanl. scanl' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (b -> a -> b) -> b -> arr1 a -> arr2 b -- | A variant of scanl whose function argument takes the current -- index as an argument. iscanl :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (Int -> b -> a -> b) -> b -> arr1 a -> arr2 b -- | A strictly accumulating version of iscanl. iscanl' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (Int -> b -> a -> b) -> b -> arr1 a -> arr2 b -- | A prescan. -- --
-- prescanl f z = init . scanl f z ---- -- Example: prescanl (+) 0 <1,2,3,4> = <0,1,3,6> prescanl :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (b -> a -> b) -> b -> arr1 a -> arr2 b -- | Like prescanl, but with a strict accumulator. prescanl' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (b -> a -> b) -> b -> arr1 a -> arr2 b -- | A variant of prescanl where the function argument takes the -- current index of the array as an additional argument. iprescanl :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (Int -> b -> a -> b) -> b -> arr1 a -> arr2 b -- | Like iprescanl, but with a strict accumulator. iprescanl' :: (Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (Int -> b -> a -> b) -> b -> arr1 a -> arr2 b mapAccum' :: forall arr1 arr2 a b c. (Contiguous arr1, Contiguous arr2, Element arr1 b, Element arr2 c, Monoid a) => (b -> (a, c)) -> arr1 b -> (a, arr2 c) -- | Monadic accumulating strict left fold over the elements on an array. mapAccumLM' :: (Contiguous arr1, Contiguous arr2, Element arr1 b, Element arr2 c, Monad m) => (a -> b -> m (a, c)) -> a -> arr1 b -> m (a, arr2 c) -- | Convert a list into an array. fromList :: (Contiguous arr, Element arr a) => [a] -> arr a -- | Given an Int that is representative of the length of the list, -- convert the list into a mutable array of the given length. -- -- Note: calls error if the given length is incorrect. fromListN :: (Contiguous arr, Element arr a) => Int -> [a] -> arr a -- | Convert a list into a mutable array of the given length. fromListMutable :: (Contiguous arr, Element arr a, PrimMonad m) => [a] -> m (Mutable arr (PrimState m) a) -- | Given an Int that is representative of the length of the list, -- convert the list into a mutable array of the given length. -- -- Note: calls error if the given length is incorrect. fromListMutableN :: (Contiguous arr, Element arr a, PrimMonad m) => Int -> [a] -> m (Mutable arr (PrimState m) a) -- | Create an array from a list. If the given length does not match the -- actual length, this function has undefined behavior. unsafeFromListN :: (Contiguous arr, Element arr a) => Int -> [a] -> arr a -- | Create an array from a list, reversing the order of the elements. If -- the given length does not match the actual length, this function has -- undefined behavior. unsafeFromListReverseN :: (Contiguous arr, Element arr a) => Int -> [a] -> arr a -- | Create a mutable array from a list, reversing the order of the -- elements. If the given length does not match the actual length, this -- function has undefined behavior. unsafeFromListReverseMutableN :: (Contiguous arr, Element arr a, PrimMonad m) => Int -> [a] -> m (Mutable arr (PrimState m) a) -- | Convert an array to a list. toList :: (Contiguous arr, Element arr a) => arr a -> [a] -- | Convert a mutable array to a list. toListMutable :: (Contiguous arr, Element arr a, PrimMonad m) => Mutable arr (PrimState m) a -> m [a] -- | Convert one type of array into another. convert :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 b) => arr1 b -> arr2 b -- | Lift an array (i.e. point to the data through an intervening thunk). lift :: ContiguousU arr => Unlifted arr b -> arr b -- | Lift a mutable array (i.e. point to the data through an intervening -- thunk). liftMut :: ContiguousU arr => UnliftedMut arr s b -> Mutable arr s b -- | Unlift an array (i.e. point to the data without an intervening thunk). unlift :: ContiguousU arr => arr b -> Unlifted arr b -- | Unlift a mutable array (i.e. point to the data without an intervening -- thunk). unliftMut :: ContiguousU arr => Mutable arr s b -> UnliftedMut arr s b -- | Clone a slice of an array. clone :: (Contiguous arr, Element arr b) => Sliced arr b -> arr b -- | Clone a slice of a mutable array. cloneMut :: (Contiguous arr, PrimMonad m, Element arr b) => MutableSliced arr (PrimState m) b -> m (Mutable arr (PrimState m) b) -- | Copy a slice of an array into a mutable array. copy :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Sliced arr b -> m () -- | Copy a slice of a mutable array into another mutable array. In the -- case that the destination and source arrays are the same, the regions -- may overlap. copyMut :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> MutableSliced arr (PrimState m) b -> m () -- | Turn a mutable array slice an immutable array by copying. freeze :: (Contiguous arr, PrimMonad m, Element arr a) => MutableSliced arr (PrimState m) a -> m (arr a) -- | Copy a slice of an immutable array into a new mutable array. thaw :: (Contiguous arr, PrimMonad m, Element arr b) => Sliced arr b -> m (Mutable arr (PrimState m) b) -- | Turn a mutable array into an immutable one without copying. The -- mutable array should not be used after this conversion. unsafeFreeze :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m (arr b) -- | Lift an accumulating hash function over the elements of the array, -- returning the final accumulated hash. liftHashWithSalt :: (Contiguous arr, Element arr a) => (Int -> a -> Int) -> Int -> arr a -> Int -- | Reduce the array and all of its elements to WHNF. rnf :: (Contiguous arr, NFData a, Element arr a) => arr a -> () -- | The Contiguous typeclass as an interface to a multitude of -- contiguous structures. -- -- Some functions do not make sense on slices; for those, see -- ContiguousU. class Contiguous (arr :: Type -> Type) where { -- | The Mutable counterpart to the array. type Mutable arr = (r :: Type -> Type -> Type) | r -> arr; -- | The constraint needed to store elements in the array. type Element arr :: Type -> Constraint; -- | The slice type of this array. The slice of a raw array type t -- should be 'Slice t', whereas the slice of a slice should be the same -- slice type. type Sliced arr :: Type -> Type; -- | The mutable slice type of this array. The mutable slice of a raw array -- type t should be 'MutableSlice t', whereas the mutable slice -- of a mutable slice should be the same slice type. type MutableSliced arr :: Type -> Type -> Type; } -- | The ContiguousU typeclass is an extension of the -- Contiguous typeclass, but includes operations that make sense -- only on unsliced contiguous structures. class (Contiguous arr) => ContiguousU arr -- | A typeclass that is satisfied by all types. This is used used to -- provide a fake constraint for Array and SmallArray. class Always a -- | Boxed arrays. data () => Array a -- | Mutable boxed arrays associated with a primitive state token. data () => MutableArray s a data () => SmallArray a data () => SmallMutableArray s 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. data () => PrimArray 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 converted 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. data () => MutablePrimArray s a -- | A type synonym for an UnliftedArray_ containing lifted values -- of a particular type. As a general rule, this type synonym should not -- be used in class instances—use UnliftedArray_ with an equality -- constraint instead. It also should not be used when defining newtypes -- or datatypes, unless those will have restrictive type roles -- regardless—use UnliftedArray_ instead. type UnliftedArray a = UnliftedArray_ Unlifted a a -- | A mutable version of MutableUnliftedArray_. type MutableUnliftedArray s a = MutableUnliftedArray_ Unlifted a s a