-- 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, PrimArray, and
-- UnliftedArray.
@package contiguous
@version 0.3.3.0
module Data.Primitive.Contiguous
-- | A contiguous array of elements.
class Contiguous (arr :: Type -> Type) where {
type family Mutable arr = (r :: Type -> Type -> Type) | r -> arr;
type family Element arr :: Type -> Constraint;
}
empty :: Contiguous arr => arr a
null :: Contiguous arr => arr b -> Bool
new :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> m (Mutable arr (PrimState m) b)
replicateM :: (Contiguous arr, PrimMonad m, Element arr b) => Int -> b -> m (Mutable arr (PrimState m) b)
index :: (Contiguous arr, Element arr b) => arr b -> Int -> b
index# :: (Contiguous arr, Element arr b) => arr b -> Int -> (# b #)
indexM :: (Contiguous arr, Element arr b, Monad m) => arr b -> Int -> m b
read :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m b
write :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> b -> m ()
resize :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> m (Mutable arr (PrimState m) b)
size :: (Contiguous arr, Element arr b) => arr b -> Int
sizeMutable :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> m Int
unsafeFreeze :: (Contiguous arr, PrimMonad m) => Mutable arr (PrimState m) b -> m (arr b)
freeze :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Int -> m (arr b)
thaw :: (Contiguous arr, PrimMonad m, Element arr b) => arr b -> Int -> Int -> m (Mutable arr (PrimState m) b)
copy :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> arr b -> Int -> Int -> m ()
copyMutable :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Mutable arr (PrimState m) b -> Int -> Int -> m ()
clone :: (Contiguous arr, Element arr b) => arr b -> Int -> Int -> arr b
cloneMutable :: (Contiguous arr, PrimMonad m, Element arr b) => Mutable arr (PrimState m) b -> Int -> Int -> m (Mutable arr (PrimState m) b)
equals :: (Contiguous arr, Element arr b, Eq b) => arr b -> arr b -> Bool
unlift :: Contiguous arr => arr b -> ArrayArray#
lift :: Contiguous arr => ArrayArray# -> arr b
sameMutable :: Contiguous arr => Mutable arr s a -> Mutable arr s a -> Bool
singleton :: (Contiguous arr, Element arr a) => a -> arr a
doubleton :: (Contiguous arr, Element arr a) => a -> a -> arr a
tripleton :: (Contiguous arr, Element arr a) => a -> a -> a -> arr a
rnf :: (Contiguous arr, NFData a, Element arr a) => arr a -> ()
-- | A typeclass that is satisfied by all types. This is used used to
-- provide a fake constraint for Array and SmallArray.
class Always a
append :: (Contiguous arr, Element arr a) => arr a -> arr a -> arr a
-- | Map over the elements of an array.
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.
map' :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c
-- | 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
-- | 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 ()
-- | 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 ()
-- | Right fold over the element 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 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.
ifoldl' :: (Contiguous arr, Element arr a) => (b -> Int -> a -> 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
-- | 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 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
traverse :: (Contiguous arr, Element arr a, Element arr b, Applicative f) => (a -> f b) -> arr a -> f (arr b)
traverseP :: (PrimMonad m, Contiguous arr1, Contiguous arr2, Element arr1 a, Element arr2 b) => (a -> m b) -> arr1 a -> m (arr2 b)
traverse_ :: (Contiguous arr, Element arr a, Applicative f) => (a -> f b) -> arr a -> f ()
itraverse_ :: (Contiguous arr, Element arr a, Applicative f) => (Int -> a -> f b) -> arr a -> f ()
-- | 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
liftHashWithSalt :: (Contiguous arr, Element arr a) => (Int -> a -> Int) -> Int -> arr a -> Int
-- | 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 :: Contiguous arr => arr a -> arr a -> Bool
instance Data.Primitive.Contiguous.Contiguous Data.Primitive.PrimArray.PrimArray
instance Data.Primitive.Contiguous.Contiguous Data.Primitive.Array.Array
instance Data.Primitive.Contiguous.Contiguous Data.Primitive.UnliftedArray.UnliftedArray
instance Data.Primitive.Contiguous.Always a