empty :: Bytes { } #
singleton :: Word8 -> Bytes { } #
O(1). A byte array with a single element.
pack :: [Word8] -> Bytes { } #
O(n). Pack a list of bytes.
unpack :: Bytes -> [Word8] { } #
O(n). Unpack to a list.
replicate :: Int -> Word8 -> Bytes { } #
O(n). Replicate a byte n times.
generate :: Int -> (Int -> Word8) -> Bytes { } #
O(n). Generate bytes using a function.
length :: Bytes -> Int { } #
O(1). Length in bytes.
null :: Bytes -> Bool { } #
O(1). Test if empty.
index :: Bytes -> Int -> Word8 { } #
O(1). Index a byte (unsafe).
!? :: Bytes -> Int -> Maybe Word8 { } #
O(1). Safe indexing.
head :: Bytes -> Word8 { } #
O(1). First byte (unsafe on empty).
tail :: Bytes -> Bytes { } #
O(1). All but the first byte (view).
last :: Bytes -> Word8 { } #
O(1). Last byte (unsafe on empty).
init :: Bytes -> Bytes { } #
O(1). All but the last byte (view).
take :: Int -> Bytes -> Bytes { } #
O(1). Take first n bytes (view).
drop :: Int -> Bytes -> Bytes { } #
O(1). Drop first n bytes (view).
splitAt :: Int -> Bytes -> (Bytes, Bytes) { } #
O(1). Split at position (views).
slice :: Int -> Int -> Bytes -> Bytes { } #
O(1). Slice from start to end indices (view).
takeWhile :: (Word8 -> Bool) -> Bytes -> Bytes { } #
O(n). Take while predicate holds.
dropWhile :: (Word8 -> Bool) -> Bytes -> Bytes { } #
O(n). Drop while predicate holds.
span :: (Word8 -> Bool) -> Bytes -> (Bytes, Bytes) { } #
O(n). Split at first element not satisfying predicate.
break :: (Word8 -> Bool) -> Bytes -> (Bytes, Bytes) { } #
O(n). Split at first element satisfying predicate.
append :: Bytes -> Bytes -> Bytes { } #
O(n). Append two byte arrays.
concat :: [Bytes] -> Bytes { } #
O(n). Concatenate a list of byte arrays.
intercalate :: Bytes -> [Bytes] -> Bytes { } #
O(n). Intercalate a separator.
elem :: Word8 -> Bytes -> Bool { } #
O(n). Test membership.
notElem :: Word8 -> Bytes -> Bool { } #
O(n). Test non-membership.
find :: (Word8 -> Bool) -> Bytes -> Maybe Word8 { } #
O(n). Find first element satisfying predicate.
findIndex :: (Word8 -> Bool) -> Bytes -> Maybe Int { } #
O(n). Find index of first element satisfying predicate.
findIndices :: (Word8 -> Bool) -> Bytes -> [Int] { } #
O(n). Find all indices of elements satisfying predicate.
elemIndex :: Word8 -> Bytes -> Maybe Int { } #
O(n). Find index of element.
elemIndices :: Word8 -> Bytes -> [Int] { } #
O(n). Find all indices of element.
map :: (Word8 -> Word8) -> Bytes -> Bytes { } #
O(n). Map a function over bytes.
reverse :: Bytes -> Bytes { } #
O(n). Reverse byte order.
intersperse :: Word8 -> Bytes -> Bytes { } #
O(n). Intersperse a byte between elements.
transpose :: [Bytes] -> [Bytes] { } #
O(n*m). Transpose rows and columns.
foldl :: (a -> Word8 -> a) -> a -> Bytes -> a { } #
O(n). Left fold.
foldl' :: (a -> Word8 -> a) -> a -> Bytes -> a { } #
O(n). Strict left fold.
foldr :: (Word8 -> a -> a) -> a -> Bytes -> a { } #
O(n). Right fold.
foldl1 :: (Word8 -> Word8 -> Word8) -> Bytes -> Word8 { } #
O(n). Left fold without starting value.
foldr1 :: (Word8 -> Word8 -> Word8) -> Bytes -> Word8 { } #
O(n). Right fold without starting value.
all :: (Word8 -> Bool) -> Bytes -> Bool { } #
O(n). Test if all elements satisfy predicate.
any :: (Word8 -> Bool) -> Bytes -> Bool { } #
O(n). Test if any element satisfies predicate.
maximum :: Bytes -> Word8 { } #
O(n). Maximum element.
minimum :: Bytes -> Word8 { } #
O(n). Minimum element.
sum :: Bytes -> Int { } #
O(n). Sum of elements.
scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> Bytes -> Bytes { } #
O(n). Scan left.
scanr :: (Word8 -> Word8 -> Word8) -> Word8 -> Bytes -> Bytes { } #
O(n). Scan right.
unfoldr :: (a -> Maybe (Word8, a)) -> a -> Bytes { } #
O(n). Build from unfolding function.
zip :: Bytes -> Bytes -> [(Word8, Word8)] { } #
O(n). Zip two byte arrays.
zipWith :: (Word8 -> Word8 -> a) -> Bytes -> Bytes -> [a] { } #
O(n). Zip with function.
unzip :: [(Word8, Word8)] -> (Bytes, Bytes) { } #
O(n). Unzip pairs.
toPinned :: Bytes -> PinnedBytes { } #
O(n). Copy to pinned memory.
fromPinned :: PinnedBytes -> Bytes { } #
O(1). Convert pinned to regular (view).
withPinnedPtr :: PinnedBytes -> ((Ptr Word8) -> IO a) -> IO a { } #
Execute action with pointer to pinned data.
unsafePinnedPtr :: PinnedBytes -> Ptr Word8 { } #
Get raw pointer (unsafe, caller manages lifetime).
new :: Int -> IO (MutableBytes RealWorld) { } #
O(n). Allocate new mutable byte array.
read :: (MutableBytes s) -> Int -> ST s Word8 { } #
O(1). Read byte at index.
write :: (MutableBytes s) -> Int -> Word8 -> ST s () { } #
O(1). Write byte at index.
modify :: (MutableBytes s) -> Int -> (Word8 -> Word8) -> ST s () { } #
O(1). Modify byte at index.
freeze :: (MutableBytes s) -> ST s Bytes { } #
O(n). Freeze mutable to immutable.
thaw :: Bytes -> ST s (MutableBytes s) { } #
O(n). Thaw immutable to mutable.
copy :: (MutableBytes s) -> Int -> (MutableBytes s) -> Int -> Int -> ST s () { } #
O(n). Copy bytes between mutable arrays.
toList :: Bytes -> [Word8] { } #
O(n). Convert to list.
fromList :: [Word8] -> Bytes { } #
O(n). Convert from list.
toStrict :: Bytes -> Bytes { } #
O(1). Convert lazy to strict.
fromStrict :: Bytes -> Bytes { } #
O(1). Convert strict to lazy.
encodeUtf8 :: Text -> Bytes { } #
Encode Text to UTF-8 bytes.
decodeUtf8 :: Bytes -> Text { } #
Decode UTF-8 bytes to Text (unsafe on invalid).
decodeUtf8' :: Bytes -> Either String Text { } #
Decode UTF-8 with error handling.
encodeBase64 :: Bytes -> Bytes { } #
Encode to Base64.
decodeBase64 :: Bytes -> Either String Bytes { } #
Decode from Base64.
readFile :: FilePath -> IO Bytes { } #
Read entire file as bytes.
writeFile :: FilePath -> Bytes -> IO () { } #
Write bytes to file.
appendFile :: FilePath -> Bytes -> IO () { } #
Append bytes to file.
hGet :: Handle -> Int -> IO Bytes { } #
Read n bytes from handle.
hPut :: Handle -> Bytes -> IO () { } #
Write bytes to handle.
hGetLine :: Handle -> IO Bytes { } #
Read line from handle.
hGetContents :: Handle -> IO Bytes { } #
Read all remaining contents.