-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Slicing managed and unmanaged memory
--
-- This library provides types that allow the user to talk about a slice
-- of a ByteArray or a MutableByteArray. It also offers UnmanagedBytes,
-- which is kind of like a slice into unmanaged memory. However, it is
-- just an address and a length.
@package byteslice
@version 0.1.2.0
module Data.Bytes.Types
-- | A slice of a ByteArray.
data Bytes
Bytes :: {-# UNPACK #-} !ByteArray -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Bytes
[$sel:array:Bytes] :: Bytes -> {-# UNPACK #-} !ByteArray
[$sel:offset:Bytes] :: Bytes -> {-# UNPACK #-} !Int
[$sel:length:Bytes] :: Bytes -> {-# UNPACK #-} !Int
-- | A slice of a MutableByteArray.
data MutableBytes s
MutableBytes :: {-# UNPACK #-} !MutableByteArray s -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> MutableBytes s
[$sel:array:MutableBytes] :: MutableBytes s -> {-# UNPACK #-} !MutableByteArray s
[$sel:offset:MutableBytes] :: MutableBytes s -> {-# UNPACK #-} !Int
[$sel:length:MutableBytes] :: MutableBytes s -> {-# UNPACK #-} !Int
-- | A slice of unmanaged memory.
data UnmanagedBytes
UnmanagedBytes :: {-# UNPACK #-} !Addr -> {-# UNPACK #-} !Int -> UnmanagedBytes
[$sel:address:UnmanagedBytes] :: UnmanagedBytes -> {-# UNPACK #-} !Addr
[$sel:length:UnmanagedBytes] :: UnmanagedBytes -> {-# UNPACK #-} !Int
instance GHC.Exts.IsList Data.Bytes.Types.Bytes
instance GHC.Show.Show Data.Bytes.Types.Bytes
instance GHC.Classes.Eq Data.Bytes.Types.Bytes
instance GHC.Classes.Ord Data.Bytes.Types.Bytes
instance GHC.Base.Semigroup Data.Bytes.Types.Bytes
module Data.Bytes.Mutable
-- | A slice of a MutableByteArray.
data MutableBytes s
-- | Take bytes while the predicate is true, aliasing the argument array.
takeWhile :: PrimMonad m => (Word8 -> m Bool) -> MutableBytes (PrimState m) -> m (MutableBytes (PrimState m))
-- | Drop bytes while the predicate is true, aliasing the argument array.
dropWhile :: PrimMonad m => (Word8 -> m Bool) -> MutableBytes (PrimState m) -> m (MutableBytes (PrimState m))
-- | Take the first n bytes from the argument, aliasing it.
unsafeTake :: Int -> MutableBytes s -> MutableBytes s
-- | Drop the first n bytes from the argument, aliasing it. The
-- new length will be len - n.
unsafeDrop :: Int -> MutableBytes s -> MutableBytes s
-- | Create a slice of MutableBytes that spans the entire argument
-- array. This aliases the argument.
fromMutableByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> m (MutableBytes (PrimState m))
module Data.Bytes
-- | A slice of a ByteArray.
data Bytes
-- | Is the byte sequence empty?
null :: Bytes -> Bool
-- | The length of a slice of bytes.
length :: Bytes -> Int
-- | Take bytes while the predicate is true.
takeWhile :: (Word8 -> Bool) -> Bytes -> Bytes
-- | Drop bytes while the predicate is true.
dropWhile :: (Word8 -> Bool) -> Bytes -> Bytes
-- | Take the first n bytes from the argument. Precondition: n
-- ≤ len
unsafeTake :: Int -> Bytes -> Bytes
-- | Drop the first n bytes from the argument. Precondition: n
-- ≤ len
unsafeDrop :: Int -> Bytes -> Bytes
-- | Convert the sliced Bytes to an unsliced ByteArray. This
-- reuses the array backing the sliced Bytes if the slicing
-- metadata implies that all of the bytes are used. Otherwise, it makes a
-- copy.
toByteArray :: Bytes -> ByteArray
-- | Variant of toByteArray that unconditionally makes a copy of the
-- array backing the sliced Bytes even if the original array could
-- be reused. Prefer toByteArray.
toByteArrayClone :: Bytes -> ByteArray
-- | Convert a String consisting of only characters in the ASCII
-- block.
fromAsciiString :: String -> Bytes
-- | Create a slice of Bytes that spans the entire argument array.
fromByteArray :: ByteArray -> Bytes