| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
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
- data MutableBytes s
 - takeWhile :: PrimMonad m => (Word8 -> m Bool) -> MutableBytes (PrimState m) -> m (MutableBytes (PrimState m))
 - dropWhile :: PrimMonad m => (Word8 -> m Bool) -> MutableBytes (PrimState m) -> m (MutableBytes (PrimState m))
 - unsafeTake :: Int -> MutableBytes s -> MutableBytes s
 - unsafeDrop :: Int -> MutableBytes s -> MutableBytes s
 - fromMutableByteArray :: PrimMonad m => MutableByteArray (PrimState m) -> m (MutableBytes (PrimState m))
 
Types
data MutableBytes s Source #
A slice of a MutableByteArray.
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.