Module

Data.ByteString

#Octet

type Octet = Int / Mod256

An 8-bit non-negative integer.

#unsafeFreeze

unsafeFreeze :: Buffer -> ByteString

O(1) The result points directly into the buffer. Mutating the buffer afterwards results in undefined behavior.

#unsafeThaw

unsafeThaw :: ByteString -> Buffer

O(1) The result points directly into the byte string. Mutating the buffer results in undefined behavior.

#empty

empty :: ByteString

O(1) The empty byte string.

#singleton

singleton :: Octet -> ByteString

O(1) A byte string with a single byte.

#pack

pack :: Array Octet -> ByteString

Θ(n) A byte string with many bytes.

#unpack

unpack :: ByteString -> Array Octet

Θ(n) Get the bytes from a byte string.

#index

index :: ByteString -> Int -> Maybe Octet

O(1) Get the nth byte.

#(!!)

Operator alias for Data.ByteString.index (left-associative / precedence 8)

#unsafeIndex

unsafeIndex :: ByteString -> Int -> Octet

O(1) Get the nth byte. If the index is out of bounds, the behavior is undefined.

#cons

cons :: Octet -> ByteString -> ByteString

Θ(n) Prepend a byte.

#snoc

snoc :: ByteString -> Octet -> ByteString

Θ(n) Append a byte.

#uncons

uncons :: ByteString -> Maybe { head :: Octet, tail :: ByteString }

Θ(n) Unprepend a byte.

#unsnoc

unsnoc :: ByteString -> Maybe { init :: ByteString, last :: Octet }

Θ(n) Unappend a byte.

#head

head :: ByteString -> Maybe Octet

O(1) Get the first byte.

#tail

tail :: ByteString -> Maybe ByteString

Θ(n) Get all but the first byte.

#last

last :: ByteString -> Maybe Octet

O(1) Get the last byte.

#init

init :: ByteString -> Maybe ByteString

Θ(n) Get all but the last byte.

#length

length :: ByteString -> Int

O(1) How many bytes are in this byte string?

#isEmpty

isEmpty :: ByteString -> Boolean

O(1) Check if a byte string is empty.

#map

map :: (Octet -> Octet) -> ByteString -> ByteString

Θ(n) Transform the bytes in the byte string.

#reverse

reverse :: ByteString -> ByteString

Θ(n) Reverse the byte string.

#Foldable

newtype Foldable a

A foldable byte string.

Instances

#foldableOfOctet

foldableOfOctet :: forall a. Foldable a -> a ~ Octet

O(1) Witness that foldable byte strings can only contain octets.

#foldl

foldl :: forall a. (a -> Octet -> a) -> a -> ByteString -> a

Θ(n) Fold a byte string.

#foldr

foldr :: forall a. (Octet -> a -> a) -> a -> ByteString -> a

Θ(n) Fold a byte string.

#fromString

fromString :: String -> Encoding -> Maybe ByteString

Θ(n) Encode a string.

#toString

toString :: ByteString -> Encoding -> String

Θ(n) Decode a string.

#toUTF8

toUTF8 :: String -> ByteString

Θ(n) unsafePartial fromJust <<< flip fromString UTF8.

#fromUTF8

fromUTF8 :: ByteString -> String

Θ(n) flip toString UTF8

Re-exports from Node.Encoding

Modules