-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Primitive byte array with type variable -- -- Primitive byte array with type variable @package prim-array @version 0.2.1 -- | Note: Edward Kmett wrote everything in this module. It was sitting -- unpackaged on github, so I took it and published it as a part of this -- package. module Data.Primitive.PrimRef newtype PrimRef s a PrimRef :: (MutableByteArray s) -> PrimRef s a -- | Create a primitive reference. newPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a) -- | Create a pinned primitive reference. newPinnedPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a) -- | Create a pinned primitive reference with the appropriate alignment for -- its contents. newAlignedPinnedPrimRef :: (PrimMonad m, Prim a) => a -> m (PrimRef (PrimState m) a) -- | Read a primitive value from the reference readPrimRef :: (PrimMonad m, Prim a) => PrimRef (PrimState m) a -> m a -- | Write a primitive value to the reference writePrimRef :: (PrimMonad m, Prim a) => PrimRef (PrimState m) a -> a -> m () -- | Yield a pointer to the data of a PrimRef. This operation is -- only safe on pinned byte arrays allocated by newPinnedPrimRef -- or newAlignedPinnedPrimRef. primRefContents :: PrimRef s a -> Addr newtype FrozenPrimRef a FrozenPrimRef :: ByteArray -> FrozenPrimRef a newFrozenPrimRef :: Prim a => a -> FrozenPrimRef a -- | Convert a mutable PrimRef to an immutable one without copying. -- The reference should not be modified after the conversion. unsafeFreezePrimRef :: PrimMonad m => PrimRef (PrimState m) a -> m (FrozenPrimRef a) -- | Convert an immutable primitive reference to a mutable one without -- copying. The original reference should not be used after the -- conversion. unsafeThawPrimRef :: PrimMonad m => FrozenPrimRef a -> m (PrimRef (PrimState m) a) -- | Read the stored primitive value from the frozen reference. indexFrozenPrimRef :: Prim a => FrozenPrimRef a -> a -- | Yield a pointer to the data of a FrozenPrimRef. This operation -- is only safe on pinned byte arrays allocated by -- newPinnedPrimRef or newAlignedPinnedPrimRef and then -- subsequently frozen. frozenPrimRefContents :: FrozenPrimRef a -> Addr -- | Given a primitive reference, the expected old value, and the new -- value, perform an atomic compare and swap i.e. write the new value if -- the current value matches the provided old value. Returns the value of -- the element before the operation. Implies a full memory barrier. casInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> Int -> m Int -- | Given a reference, and a value to add, atomically add the value to the -- element. Returns the value of the element before the operation. -- Implies a full memory barrier. fetchAddInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int -- | Given a reference, and a value to subtract, atomically subtract the -- value from the element. Returns the value of the element before the -- operation. Implies a full memory barrier. fetchSubInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int -- | Given a reference, and a value to bitwise and, atomically and the -- value with the element. Returns the value of the element before the -- operation. Implies a full memory barrier. fetchAndInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int -- | Given a reference, and a value to bitwise nand, atomically nand the -- value with the element. Returns the value of the element before the -- operation. Implies a full memory barrier. fetchNandInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int -- | Given a reference, and a value to bitwise or, atomically or the value -- with the element. Returns the value of the element before the -- operation. Implies a full memory barrier. fetchOrInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int -- | Given a reference, and a value to bitwise xor, atomically xor the -- value with the element. Returns the value of the element before the -- operation. Implies a full memory barrier. fetchXorInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m Int -- | Given a reference, read an element. Implies a full memory barrier. atomicReadInt :: PrimMonad m => PrimRef (PrimState m) Int -> m Int -- | Given a reference, write an element. Implies a full memory barrier. atomicWriteInt :: PrimMonad m => PrimRef (PrimState m) Int -> Int -> m () instance GHC.Classes.Eq (Data.Primitive.PrimRef.PrimRef s a) instance (Data.Primitive.Types.Prim a, Data.Data.Data a) => Data.Data.Data (Data.Primitive.PrimRef.FrozenPrimRef a) module Data.Primitive.PrimArray -- | Primitive arrays data PrimArray a PrimArray :: ByteArray# -> PrimArray a -- | Mutable primitive arrays associated with a primitive state token data MutablePrimArray s a MutablePrimArray :: (MutableByteArray# s) -> MutablePrimArray s a newPrimArray :: forall m a. (PrimMonad m, Prim a) => Int -> m (MutablePrimArray (PrimState m) a) emptyPrimArray :: PrimArray a singletonPrimArray :: Prim a => a -> PrimArray a readPrimArray :: (Prim a, PrimMonad m) => MutablePrimArray (PrimState m) a -> Int -> m a writePrimArray :: (Prim a, PrimMonad m) => MutablePrimArray (PrimState m) a -> Int -> a -> m () -- | Read a primitive value from the array. indexPrimArray :: forall a. Prim a => PrimArray a -> Int -> a -- | Convert a mutable byte array to an immutable one without copying. The -- array should not be modified after the conversion. unsafeFreezePrimArray :: PrimMonad m => MutablePrimArray (PrimState m) a -> m (PrimArray a) -- | Convert an immutable array to a mutable one without copying. The -- original array should not be used after the conversion. unsafeThawPrimArray :: PrimMonad m => PrimArray a -> m (MutablePrimArray (PrimState m) a) -- | Copy part of an array into another mutable array. copyPrimArray :: forall m a. (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> Int -> PrimArray a -> Int -> Int -> m () -- | Copy part of a mutable array into another mutable array. In the case -- that the destination and source arrays are the same, the regions may -- overlap. copyMutablePrimArray :: forall m a. (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> Int -> MutablePrimArray (PrimState m) a -> Int -> Int -> m () -- | Copy a slice of an immutable primitive array to an address. The offset -- and length are given in elements of type a. copyPrimArrayToPtr :: forall m a. (PrimMonad m, Prim a) => Ptr a -> PrimArray a -> Int -> Int -> m () copyPtrToMutablePrimArray :: forall m a. (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> Int -> Ptr a -> Int -> m () copyPtrToPrimArray :: forall a. Prim a => Ptr a -> Int -> PrimArray a -- | Fill a slice of a mutable byte array with a value. setPrimArray :: (Prim a, PrimMonad m) => MutablePrimArray (PrimState m) a -> Int -> Int -> a -> m () -- | Check if the two arrays refer to the same memory block. sameMutablePrimArray :: MutablePrimArray s a -> MutablePrimArray s a -> Bool -- | Get the size of the mutable array. getSizeofMutablePrimArray :: forall m a. (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> m Int sizeofPrimArray :: forall a. Prim a => PrimArray a -> Int instance (GHC.Classes.Eq a, Data.Primitive.Types.Prim a) => GHC.Classes.Eq (Data.Primitive.PrimArray.PrimArray a) instance Data.Primitive.Types.Prim a => GHC.Exts.IsList (Data.Primitive.PrimArray.PrimArray a) instance (Data.Primitive.Types.Prim a, GHC.Show.Show a) => GHC.Show.Show (Data.Primitive.PrimArray.PrimArray a) instance Data.Primitive.Types.Prim a => GHC.Base.Monoid (Data.Primitive.PrimArray.PrimArray a)