byteslice-0.2.6.0: Slicing managed and unmanaged memory
Safe HaskellNone
LanguageHaskell2010

Data.Bytes.Mutable

Description

If you are interested in sub-arrays of MutableByteArrays (e.g. writing quicksort), it would be grossly inefficient to make a copy of the sub-array. On the other hand, it'd be really annoying to track limit indices by hand.

This module defines the MutableBytes type which exposes a standard array interface for a sub-arrays without copying and without manual index manipulation. For immutable arrays, see Bytes.

Synopsis

Types

Filtering

takeWhile :: PrimMonad m => (Word8 -> m Bool) -> MutableBytes (PrimState m) -> m (MutableBytes (PrimState m)) Source #

Take bytes while the predicate is true, aliasing the argument array.

dropWhile :: PrimMonad m => (Word8 -> m Bool) -> MutableBytes (PrimState m) -> m (MutableBytes (PrimState m)) Source #

Drop bytes while the predicate is true, aliasing the argument array.

Unsafe Slicing

unsafeTake :: Int -> MutableBytes s -> MutableBytes s Source #

Take the first n bytes from the argument, aliasing it.

unsafeDrop :: Int -> MutableBytes s -> MutableBytes s Source #

Drop the first n bytes from the argument, aliasing it. The new length will be len - n.

Conversion

fromMutableByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> m (MutableBytes (PrimState m)) Source #

Create a slice of MutableBytes that spans the entire argument array. This aliases the argument.