-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Addresses to unmanaged memory
--   
--   This library provides the <a>Data.Primitive.Addr</a> module that was a
--   part of the <a>primitive</a> library before `primitive-0.7.0.0`.
@package primitive-addr
@version 0.1.0.3


-- | Primitive operations on machine addresses.
module Data.Primitive.Addr

-- | A machine address
data Addr
Addr :: Addr# -> Addr

-- | The null address
nullAddr :: Addr

-- | Offset an address by the given number of bytes
plusAddr :: Addr -> Int -> Addr
infixl 6 `plusAddr`

-- | Distance in bytes between two addresses. The result is only valid if
--   the difference fits in an <a>Int</a>.
minusAddr :: Addr -> Addr -> Int
infixl 6 `minusAddr`

-- | The remainder of the address and the integer.
remAddr :: Addr -> Int -> Int
infixl 7 `remAddr`

-- | 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 <tt>a</tt> rather than in bytes.
indexOffAddr :: Prim a => Addr -> Int -> a

-- | Read a value from a memory position given by an address and an offset.
--   The offset is in elements of type <tt>a</tt> rather than in bytes.
readOffAddr :: (Prim a, PrimMonad m) => Addr -> Int -> m a

-- | Write a value to a memory position given by an address and an offset.
--   The offset is in elements of type <tt>a</tt> rather than in bytes.
writeOffAddr :: (Prim a, PrimMonad m) => Addr -> Int -> a -> m ()

-- | Copy the given number of bytes from the second <a>Addr</a> to the
--   first. The areas may not overlap.
copyAddr :: PrimMonad m => Addr -> Addr -> Int -> m ()

-- | Copy the given number of bytes from the <a>Addr</a> to the
--   <a>MutableByteArray</a>. The areas may not overlap. This function is
--   only available when compiling with GHC 7.8 or newer.
copyAddrToByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> Int -> Addr -> Int -> m ()

-- | Copy the given number of bytes from the second <a>Addr</a> to the
--   first. The areas may overlap.
moveAddr :: PrimMonad m => Addr -> Addr -> Int -> m ()

-- | Fill a memory block of with the given value. The length is in elements
--   of type <tt>a</tt> rather than in bytes.
setAddr :: (Prim a, PrimMonad m) => Addr -> Int -> a -> m ()

-- | Convert an <a>Addr</a> to an <a>Int</a>.
addrToInt :: Addr -> Int
instance GHC.Classes.Eq Data.Primitive.Addr.Addr
instance GHC.Classes.Ord Data.Primitive.Addr.Addr
instance GHC.Internal.Show.Show Data.Primitive.Addr.Addr
