pipes-bytestring-2.1.7: ByteString support for pipes

Safe Haskell | Trustworthy
Language | Haskell2010

Pipes.ByteString

Contents

- Producers
- Servers
- Consumers
- Pipes
- Folds
- Parsing
- Parsing Lenses
- Transforming Byte Streams
- FreeT Transformations
- Re-exports

Description

This module provides `pipes` utilities for "byte streams", which are streams of strict `ByteString`s chunks. Use byte streams to interact with both `Handle`s and lazy `ByteString`s.

To stream to or from `Handle`s, use `fromHandle` or `toHandle`. For example, the following program copies data from one file to another:

    import Pipes
    import qualified Pipes.ByteString as P
    import System.IO

    main =
        withFile "inFile.txt"  ReadMode  $ \hIn  ->
        withFile "outFile.txt" WriteMode $ \hOut ->
        runEffect $ P.fromHandle hIn >-> P.toHandle hOut

You can stream to and from `stdin` and `stdout` using the predefined `stdin` and `stdout` pipes, like in the following "echo" program:

    main = runEffect $ P.stdin >-> P.stdout

You can also translate pure lazy `ByteString`s to and from pipes:

    import qualified Data.ByteString.Lazy.Char8 as BL

    main = runEffect $ P.fromLazy (BL.pack "Hello, world!\n") >-> P.stdout

In addition, this module provides many functions equivalent to lazy `ByteString` functions so that you can transform or fold byte streams. For example, to stream only the first three lines of `stdin` to `stdout` you would write:

    import Lens.Family (over)
    import Pipes
    import qualified Pipes.ByteString as PB
    import Pipes.Group (takes)

    main = runEffect $ over PB.lines (takes 3) PB.stdin >-> PB.stdout

The above program will never bring more than one chunk (~ 32 KB) into memory, no matter how long the lines are.

Note that functions in this library are designed to operate on streams that are insensitive to chunk boundaries. This means that they may freely split chunks into smaller chunks and discard empty chunks. However, they will never concatenate chunks in order to provide strict upper bounds on memory usage.

Synopsis

- fromLazy :: Monad m => ByteString -> Producer' ByteString m ()
- stdin :: MonadIO m => Producer' ByteString m ()
- fromHandle :: MonadIO m => Handle -> Producer' ByteString m ()
- hGetSome :: MonadIO m => Int -> Handle -> Producer' ByteString m ()
- hGetNonBlocking :: MonadIO m => Int -> Handle -> Producer' ByteString m ()
- hGet :: MonadIO m => Int -> Handle -> Producer' ByteString m ()
- hGetRange :: MonadIO m => Int -> Int -> Handle -> Producer' ByteString m ()
- hGetSomeN :: MonadIO m => Handle -> Int -> Server' Int ByteString m ()
- hGetN :: MonadIO m => Handle -> Int -> Server' Int ByteString m ()
- stdout :: MonadIO m => Consumer' ByteString m ()
- toHandle :: MonadIO m => Handle -> Consumer' ByteString m r
- map :: Monad m => (Word8 -> Word8) -> Pipe ByteString ByteString m r
- concatMap :: Monad m => (Word8 -> ByteString) -> Pipe ByteString ByteString m r
- take :: (Monad m, Integral n) => n -> Pipe ByteString ByteString m ()
- takeWhile :: Monad m => (Word8 -> Bool) -> Pipe ByteString ByteString m ()
- filter :: Monad m => (Word8 -> Bool) -> Pipe ByteString ByteString m r
- elemIndices :: (Monad m, Num n) => Word8 -> Pipe ByteString n m r
- findIndices :: (Monad m, Num n) => (Word8 -> Bool) -> Pipe ByteString n m r
- scan :: Monad m => (Word8 -> Word8 -> Word8) -> Word8 -> Pipe ByteString ByteString m r
- toLazy :: Producer ByteString Identity () -> ByteString
- toLazyM :: Monad m => Producer ByteString m () -> m ByteString
- toLazyM' :: Monad m => Producer ByteString m a -> m (ByteString, a)
- foldBytes :: Monad m => (x -> Word8 -> x) -> x -> (x -> r) -> Producer ByteString m () -> m r
- head :: Monad m => Producer ByteString m () -> m (Maybe Word8)
- last :: Monad m => Producer ByteString m () -> m (Maybe Word8)
- null :: Monad m => Producer ByteString m () -> m Bool
- length :: (Monad m, Num n) => Producer ByteString m () -> m n
- any :: Monad m => (Word8 -> Bool) -> Producer ByteString m () -> m Bool
- all :: Monad m => (Word8 -> Bool) -> Producer ByteString m () -> m Bool
- maximum :: Monad m => Producer ByteString m () -> m (Maybe Word8)
- minimum :: Monad m => Producer ByteString m () -> m (Maybe Word8)
- elem :: Monad m => Word8 -> Producer ByteString m () -> m Bool
- notElem :: Monad m => Word8 -> Producer ByteString m () -> m Bool
- find :: Monad m => (Word8 -> Bool) -> Producer ByteString m () -> m (Maybe Word8)
- index :: (Monad m, Integral n) => n -> Producer ByteString m () -> m (Maybe Word8)
- elemIndex :: (Monad m, Num n) => Word8 -> Producer ByteString m () -> m (Maybe n)
- findIndex :: (Monad m, Num n) => (Word8 -> Bool) -> Producer ByteString m () -> m (Maybe n)
- count :: (Monad m, Num n) => Word8 -> Producer ByteString m () -> m n
- nextByte :: Monad m => Producer ByteString m r -> m (Either r (Word8, Producer ByteString m r))
- drawByte :: Monad m => Parser ByteString m (Maybe Word8)
- unDrawByte :: Monad m => Word8 -> Parser ByteString m ()
- peekByte :: Monad m => Parser ByteString m (Maybe Word8)
- isEndOfBytes :: Monad m => Parser ByteString m Bool
- splitAt :: (Monad m, Integral n) => n -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- span :: Monad m => (Word8 -> Bool) -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- break :: Monad m => (Word8 -> Bool) -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- breakOn :: Monad m => ByteString -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- groupBy :: Monad m => (Word8 -> Word8 -> Bool) -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- group :: Monad m => Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- word :: Monad m => Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- line :: Monad m => Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x))
- drop :: (Monad m, Integral n) => n -> Producer ByteString m r -> Producer ByteString m r
- dropWhile :: Monad m => (Word8 -> Bool) -> Producer ByteString m r -> Producer ByteString m r
- intersperse :: Monad m => Word8 -> Producer ByteString m r -> Producer ByteString m r
- pack :: Monad m => Lens' (Producer Word8 m x) (Producer ByteString m x)
- unpack :: Monad m => Lens' (Producer ByteString m x) (Producer Word8 m x)
- chunksOf' :: (Monad m, Integral n) => n -> Producer ByteString m r -> Producer ByteString m r
- chunksOf :: (Monad m, Integral n) => n -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x)
- splitsWith :: Monad m => (Word8 -> Bool) -> Producer ByteString m x -> FreeT (Producer ByteString m) m x
- splits :: Monad m => Word8 -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x)
- splitOn :: Monad m => ByteString -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x)
- groupsBy :: Monad m => (Word8 -> Word8 -> Bool) -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x)
- groups :: Monad m => Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x)
- lines :: Monad m => Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x)
- unlines :: Monad m => Lens' (FreeT (Producer ByteString m) m x) (Producer ByteString m x)
- words :: Monad m => Producer ByteString m x -> FreeT (Producer ByteString m) m x
- unwords :: Monad m => FreeT (Producer ByteString m) m x -> Producer ByteString m x
- data ByteString
- data Word8
- data FreeT (f :: Type -> Type) (m :: Type -> Type) a
- concats :: forall (m :: Type -> Type) a x. Monad m => FreeT (Producer a m) m x -> Producer a m x
- intercalates :: forall (m :: Type -> Type) a x. Monad m => Producer a m () -> FreeT (Producer a m) m x -> Producer a m x
- type Parser a (m :: Type -> Type) r = forall x. StateT (Producer a m x) m r

# Producers

fromLazy :: Monad m => ByteString -> Producer' ByteString m () Source #

Convert a lazy `ByteString` into a `Producer` of strict `ByteString`s

stdin :: MonadIO m => Producer' ByteString m () Source #

Stream bytes from `stdin`

fromHandle :: MonadIO m => Handle -> Producer' ByteString m () Source #

Convert a `Handle` into a byte stream using a default chunk size

hGetSome :: MonadIO m => Int -> Handle -> Producer' ByteString m () Source #

Convert a handle into a byte stream using a maximum chunk size

`hGetSome` forwards input immediately as it becomes available, splitting the input into multiple chunks if it exceeds the maximum chunk size.

hGetNonBlocking :: MonadIO m => Int -> Handle -> Producer' ByteString m () Source #

Convert a handle into a byte stream using a fixed chunk size

Similar to `hGet` except that it will never block waiting for data to become available.

hGet :: MonadIO m => Int -> Handle -> Producer' ByteString m () Source #

Convert a handle into a byte stream using a fixed chunk size

`hGet` waits until exactly the requested number of bytes are available for each chunk.

hGetRange Source #

Arguments

:: MonadIO m |
=> Int | Offset
-> Int | Size
-> Handle |
-> Producer' ByteString m () |

Like `hGet` but with an extra parameter specifying an initial handle offset

# Servers

hGetSomeN :: MonadIO m => Handle -> Int -> Server' Int ByteString m () Source #

Like `hGetSome`, except you can vary the maximum chunk size for each request

hGetN :: MonadIO m => Handle -> Int -> Server' Int ByteString m () Source #

Like `hGet`, except you can vary the chunk size for each request

# Consumers

stdout :: MonadIO m => Consumer' ByteString m () Source #

Stream bytes to `stdout`

Unlike `toHandle`, `stdout` gracefully terminates on a broken output pipe.

toHandle :: MonadIO m => Handle -> Consumer' ByteString m r Source #

Convert a byte stream into a `Handle`

    p >-> toHandle handle = for p (liftIO . hPutStr handle)

# Pipes

map :: Monad m => (Word8 -> Word8) -> Pipe ByteString ByteString m r Source #

Apply a transformation to each `Word8` in the stream

concatMap :: Monad m => (Word8 -> ByteString) -> Pipe ByteString ByteString m r Source #

Map a function over the byte stream and concatenate the results

take :: (Monad m, Integral n) => n -> Pipe ByteString ByteString m () Source #

`(take n)` only allows `n` bytes to pass

takeWhile :: Monad m => (Word8 -> Bool) -> Pipe ByteString ByteString m () Source #

Take bytes until they fail the predicate

filter :: Monad m => (Word8 -> Bool) -> Pipe ByteString ByteString m r Source #

Only allows `Word8`s to pass if they satisfy the predicate

elemIndices :: (Monad m, Num n) => Word8 -> Pipe ByteString n m r Source #

Stream all indices whose elements match the given `Word8`

findIndices :: (Monad m, Num n) => (Word8 -> Bool) -> Pipe ByteString n m r Source #

Stream all indices whose elements satisfy the given predicate

scan :: Monad m => (Word8 -> Word8 -> Word8) -> Word8 -> Pipe ByteString ByteString m r Source #

Strict left scan over the bytes

# Folds

toLazy :: Producer ByteString Identity () -> ByteString Source #

Fold a pure `Producer` of strict `ByteString`s into a lazy `ByteString`

toLazyM :: Monad m => Producer ByteString m () -> m ByteString Source #

Fold an effectful `Producer` of strict `ByteString`s into a lazy `ByteString`

Note: `toLazyM` is not an idiomatic use of `pipes`, but I provide it for simple testing purposes. Idiomatic `pipes` style consumes the chunks immediately as they are generated instead of loading them all into memory.

toLazyM' :: Monad m => Producer ByteString m a -> m (ByteString, a) Source #

Fold an effectful `Producer` of strict `ByteString`s into a lazy `ByteString` alongside the return value

Note: `toLazyM'` is not an idiomatic use of `pipes`, but I provide it for simple testing purposes. Idiomatic `pipes` style consumes the chunks immediately as they are generated instead of loading them all into memory.

foldBytes :: Monad m => (x -> Word8 -> x) -> x -> (x -> r) -> Producer ByteString m () -> m r Source #

Reduce the stream of bytes using a strict left fold

Note: It's more efficient to use folds from `Control.Foldl.ByteString` in conjunction with `Pipes.Prelude.`fold`` when possible

head :: Monad m => Producer ByteString m () -> m (Maybe Word8) Source #

Retrieve the first `Word8`

last :: Monad m => Producer ByteString m () -> m (Maybe Word8) Source #

Retrieve the last `Word8`

null :: Monad m => Producer ByteString m () -> m Bool Source #

Determine if the stream is empty

length :: (Monad m, Num n) => Producer ByteString m () -> m n Source #

Count the number of bytes

any :: Monad m => (Word8 -> Bool) -> Producer ByteString m () -> m Bool Source #

Fold that returns whether `Any` received `Word8`s satisfy the predicate

all :: Monad m => (Word8 -> Bool) -> Producer ByteString m () -> m Bool Source #

Fold that returns whether `All` received `Word8`s satisfy the predicate

maximum :: Monad m => Producer ByteString m () -> m (Maybe Word8) Source #

Return the maximum `Word8` within a byte stream

minimum :: Monad m => Producer ByteString m () -> m (Maybe Word8) Source #

Return the minimum `Word8` within a byte stream

elem :: Monad m => Word8 -> Producer ByteString m () -> m Bool Source #

Determine whether any element in the byte stream matches the given `Word8`

notElem :: Monad m => Word8 -> Producer ByteString m () -> m Bool Source #

Determine whether all elements in the byte stream do not match the given `Word8`

find :: Monad m => (Word8 -> Bool) -> Producer ByteString m () -> m (Maybe Word8) Source #

Find the first element in the stream that matches the predicate

index :: (Monad m, Integral n) => n -> Producer ByteString m () -> m (Maybe Word8) Source #

Index into a byte stream

elemIndex :: (Monad m, Num n) => Word8 -> Producer ByteString m () -> m (Maybe n) Source #

Find the index of an element that matches the given `Word8`

findIndex :: (Monad m, Num n) => (Word8 -> Bool) -> Producer ByteString m () -> m (Maybe n) Source #

Store the first index of an element that satisfies the predicate

count :: (Monad m, Num n) => Word8 -> Producer ByteString m () -> m n Source #

Store a tally of how many elements match the given `Word8`

# Parsing

The following parsing utilities are single-byte analogs of the ones found in `pipes-parse`.

nextByte :: Monad m => Producer ByteString m r -> m (Either r (Word8, Producer ByteString m r)) Source #

Consume the first byte from a byte stream

`next` either fails with a `Left` if the `Producer` has no more bytes or succeeds with a `Right` providing the next byte and the remainder of the `Producer`.

drawByte :: Monad m => Parser ByteString m (Maybe Word8) Source #

Draw one `Word8` from the underlying `Producer`, returning `Nothing` if the `Producer` is empty

unDrawByte :: Monad m => Word8 -> Parser ByteString m () Source #

Push back a `Word8` onto the underlying `Producer`

peekByte :: Monad m => Parser ByteString m (Maybe Word8) Source #

`peekByte` checks the first `Word8` in the stream, but uses `unDrawByte` to push the `Word8` back

    peekByte = do
        x <- drawByte
        case x of
            Nothing -> return ()
            Just w8 -> unDrawByte w8
        return x

isEndOfBytes :: Monad m => Parser ByteString m Bool Source #

Check if the underlying `Producer` has no more bytes

Note that this will skip over empty `ByteString` chunks, unlike `isEndOfInput` from `pipes-parse`.

    isEndOfBytes = liftM isNothing peekByte

# Parsing Lenses

splitAt :: (Monad m, Integral n) => n -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Improper lens that splits a `Producer` after the given number of bytes

span :: Monad m => (Word8 -> Bool) -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Improper lens that splits after the longest consecutive group of bytes that satisfy the given predicate

break :: Monad m => (Word8 -> Bool) -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Improper lens that splits after the longest consecutive group of bytes that fail the given predicate

breakOn :: Monad m => ByteString -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Improper lens that splits at the first occurrence of the pattern.

groupBy :: Monad m => (Word8 -> Word8 -> Bool) -> Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Improper lens that splits after the first group of matching bytes, as defined by the given equality predicate

group :: Monad m => Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Like `groupBy`, where the equality predicate is (`==`)

word :: Monad m => Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Improper lens that splits a `Producer` after the first word

Unlike `words`, this does not drop leading whitespace

Note: This function is purely for demonstration purposes since it assumes a particular encoding. You should prefer the `Text` equivalent of this function from the `pipes-text` library.

line :: Monad m => Lens' (Producer ByteString m x) (Producer ByteString m (Producer ByteString m x)) Source #

Improper lens that splits a `Producer` after the first line

Unlike `lines`, this does not consume the newline marker, which is stored within the inner `Producer`

Note: This function is purely for demonstration purposes since it assumes a particular encoding. You should prefer the `Text` equivalent of this function from the `pipes-text` library.

# Transforming Byte Streams

drop :: (Monad m, Integral n) => n -> Producer ByteString m r -> Producer ByteString m r Source #

`(drop n)` drops the first `n` bytes

dropWhile :: Monad m => (Word8 -> Bool) -> Producer ByteString m r -> Producer ByteString m r Source #

Drop bytes until they fail the predicate

intersperse :: Monad m => Word8 -> Producer ByteString m r -> Producer ByteString m r Source #

Intersperse a `Word8` in between the bytes of the byte stream

pack :: Monad m => Lens' (Producer Word8 m x) (Producer ByteString m x) Source #

Improper lens from unpacked `Word8`s to packaged `ByteString`s

unpack :: Monad m => Lens' (Producer ByteString m x) (Producer Word8 m x) Source #

Improper lens from packed `ByteString`s to unpacked `Word8`s

chunksOf' :: (Monad m, Integral n) => n -> Producer ByteString m r -> Producer ByteString m r Source #

Group byte stream chunks into chunks of fixed length

Note: This is the only function in this API that concatenates `ByteString` chunks, which requires allocating new `ByteString`s

# FreeT Transformations

chunksOf :: (Monad m, Integral n) => n -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x) Source #

Split a byte stream into `FreeT`-delimited byte streams of fixed size

splitsWith :: Monad m => (Word8 -> Bool) -> Producer ByteString m x -> FreeT (Producer ByteString m) m x Source #

Split a byte stream into groups separated by bytes that satisfy the predicate

splits :: Monad m => Word8 -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x) Source #

Split a byte stream into groups separated by the given byte

splitOn :: Monad m => ByteString -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x) Source #

Split a byte stream into groups separated by the given `ByteString`

groupsBy :: Monad m => (Word8 -> Word8 -> Bool) -> Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x) Source #

Isomorphism between a byte stream and groups of identical bytes using the supplied equality predicate

groups :: Monad m => Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x) Source #

Like `groupsBy`, where the equality predicate is (`==`)

lines :: Monad m => Lens' (Producer ByteString m x) (FreeT (Producer ByteString m) m x) Source #

Improper lens between a bytestream and its lines

Note: This function is purely for demonstration purposes since it assumes a particular encoding. You should prefer the `Text` equivalent of this function from the `pipes-text` library.

unlines :: Monad m => Lens' (FreeT (Producer ByteString m) m x) (Producer ByteString m x) Source #

Improper lens between lines and a bytestream

Note: This function is purely for demonstration purposes since it assumes a particular encoding. You should prefer the `Text` equivalent of this function from the `pipes-text` library.

words :: Monad m => Producer ByteString m x -> FreeT (Producer ByteString m) m x Source #

Convert a bytestream to delimited words

Note: This function is purely for demonstration purposes since it assumes a particular encoding. You should prefer the `Text` equivalent of this function from the `pipes-text` library.

unwords :: Monad m => FreeT (Producer ByteString m) m x -> Producer ByteString m x Source #

Convert delimited words back to a byte stream

Note: This function is purely for demonstration purposes since it assumes a particular encoding. You should prefer the `Text` equivalent of this function from the `pipes-text` library.

# Re-exports

`Data.ByteString` re-exports the `ByteString` type.

`Data.Word` re-exports the `Word8` type.

`Pipes.Parse` re-exports `Parser`.

`Pipes.Group` re-exports `concats`, `intercalates`, and `FreeT` (the type).

data ByteString Source #

A space-efficient representation of a `Word8` vector, supporting many efficient operations.

A `ByteString` contains 8-bit bytes, or by using the operations from Data.ByteString.Char8 it can be interpreted as containing 8-bit characters.

#### Instances

Instances details

Data ByteString |

Instance details

Defined in Data.ByteString.Internal.Type

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteString -> c ByteString Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteString Source #

toConstr :: ByteString -> Constr Source #

dataTypeOf :: ByteString -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ByteString) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteString) Source #

gmapT :: (forall b. Data b => b -> b) -> ByteString -> ByteString Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ByteString -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteString -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source #

IsString ByteString | Beware: `fromString` truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�
Instance details Defined in Data.ByteString.Internal.Type Methods fromString :: String -> ByteString Source #
Monoid ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods mempty :: ByteString Source # mappend :: ByteString -> ByteString -> ByteString Source # mconcat :: [ByteString] -> ByteString Source #
Semigroup ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods (<>) :: ByteString -> ByteString -> ByteString Source # sconcat :: NonEmpty ByteString -> ByteString Source # stimes :: Integral b => b -> ByteString -> ByteString Source #
IsList ByteString | Since: bytestring-0.10.12.0
Instance details Defined in Data.ByteString.Internal.Type Associated Types type Item ByteString Source # Methods fromList :: [Item ByteString] -> ByteString Source # fromListN :: Int -> [Item ByteString] -> ByteString Source # toList :: ByteString -> [Item ByteString] Source #
Read ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods readsPrec :: Int -> ReadS ByteString Source # readList :: ReadS [ByteString] Source # readPrec :: ReadPrec ByteString Source # readListPrec :: ReadPrec [ByteString] Source #
Show ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods showsPrec :: Int -> ByteString -> ShowS Source # show :: ByteString -> String Source # showList :: [ByteString] -> ShowS Source #
NFData ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods rnf :: ByteString -> () Source #
Eq ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods (==) :: ByteString -> ByteString -> Bool Source # (/=) :: ByteString -> ByteString -> Bool Source #
Ord ByteString |

Instance details

Defined in Data.ByteString.Internal.Type

Methods

compare :: ByteString -> ByteString -> Ordering Source #

(<) :: ByteString -> ByteString -> Bool Source #

(<=) :: ByteString -> ByteString -> Bool Source #

(>) :: ByteString -> ByteString -> Bool Source #

(>=) :: ByteString -> ByteString -> Bool Source #

max :: ByteString -> ByteString -> ByteString Source #

min :: ByteString -> ByteString -> ByteString Source #

Lift ByteString | Since: bytestring-0.11.2.0
Instance details Defined in Data.ByteString.Internal.Type Methods lift :: Quote m => ByteString -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => ByteString -> Code m ByteString Source #
type Item ByteString |
Instance details Defined in Data.ByteString.Internal.Type type Item ByteString = Word8

data Word8 Source #

8-bit unsigned integer type

#### Instances

Instances details

Bits Word8 | Since: base-2.1

Instance details

Defined in GHC.Word

Methods

(.&.) :: Word8 -> Word8 -> Word8 Source #

(.|.) :: Word8 -> Word8 -> Word8 Source #

xor :: Word8 -> Word8 -> Word8 Source #

complement :: Word8 -> Word8 Source #

shift :: Word8 -> Int -> Word8 Source #

rotate :: Word8 -> Int -> Word8 Source #

zeroBits :: Word8 Source #

bit :: Int -> Word8 Source #

setBit :: Word8 -> Int -> Word8 Source #

clearBit :: Word8 -> Int -> Word8 Source #

complementBit :: Word8 -> Int -> Word8 Source #

testBit :: Word8 -> Int -> Bool Source #

bitSizeMaybe :: Word8 -> Maybe Int Source #

bitSize :: Word8 -> Int Source #

isSigned :: Word8 -> Bool Source #

shiftL :: Word8 -> Int -> Word8 Source #

unsafeShiftL :: Word8 -> Int -> Word8 Source #

shiftR :: Word8 -> Int -> Word8 Source #

unsafeShiftR :: Word8 -> Int -> Word8 Source #

rotateL :: Word8 -> Int -> Word8 Source #

rotateR :: Word8 -> Int -> Word8 Source #

popCount :: Word8 -> Int Source #

FiniteBits Word8 | Since: base-4.6.0.0
Instance details Defined in GHC.Word Methods finiteBitSize :: Word8 -> Int Source # countLeadingZeros :: Word8 -> Int Source # countTrailingZeros :: Word8 -> Int Source #
Bounded Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods minBound :: Word8 Source # maxBound :: Word8 Source #
Enum Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods succ :: Word8 -> Word8 Source # pred :: Word8 -> Word8 Source # toEnum :: Int -> Word8 Source # fromEnum :: Word8 -> Int Source # enumFrom :: Word8 -> [Word8] Source # enumFromThen :: Word8 -> Word8 -> [Word8] Source # enumFromTo :: Word8 -> Word8 -> [Word8] Source # enumFromThenTo :: Word8 -> Word8 -> Word8 -> [Word8] Source #
Ix Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods range :: (Word8, Word8) -> [Word8] Source # index :: (Word8, Word8) -> Word8 -> Int Source # unsafeIndex :: (Word8, Word8) -> Word8 -> Int Source # inRange :: (Word8, Word8) -> Word8 -> Bool Source # rangeSize :: (Word8, Word8) -> Int Source # unsafeRangeSize :: (Word8, Word8) -> Int Source #
Num Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods (+) :: Word8 -> Word8 -> Word8 Source # (-) :: Word8 -> Word8 -> Word8 Source # (*) :: Word8 -> Word8 -> Word8 Source # negate :: Word8 -> Word8 Source # abs :: Word8 -> Word8 Source # signum :: Word8 -> Word8 Source # fromInteger :: Integer -> Word8 Source #
Read Word8 | Since: base-2.1
Instance details Defined in GHC.Read Methods readsPrec :: Int -> ReadS Word8 Source # readList :: ReadS [Word8] Source # readPrec :: ReadPrec Word8 Source # readListPrec :: ReadPrec [Word8] Source #
Integral Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods quot :: Word8 -> Word8 -> Word8 Source # rem :: Word8 -> Word8 -> Word8 Source # div :: Word8 -> Word8 -> Word8 Source # mod :: Word8 -> Word8 -> Word8 Source # quotRem :: Word8 -> Word8 -> (Word8, Word8) Source # divMod :: Word8 -> Word8 -> (Word8, Word8) Source # toInteger :: Word8 -> Integer Source #
Real Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods toRational :: Word8 -> Rational Source #
Show Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods showsPrec :: Int -> Word8 -> ShowS Source # show :: Word8 -> String Source # showList :: [Word8] -> ShowS Source #
NFData Word8 |
Instance details Defined in Control.DeepSeq Methods rnf :: Word8 -> () Source #
Eq Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods (==) :: Word8 -> Word8 -> Bool Source # (/=) :: Word8 -> Word8 -> Bool Source #
Ord Word8 | Since: base-2.1
Instance details Defined in GHC.Word Methods compare :: Word8 -> Word8 -> Ordering Source # (<) :: Word8 -> Word8 -> Bool Source # (<=) :: Word8 -> Word8 -> Bool Source # (>) :: Word8 -> Word8 -> Bool Source # (>=) :: Word8 -> Word8 -> Bool Source # max :: Word8 -> Word8 -> Word8 Source # min :: Word8 -> Word8 -> Word8 Source #

data FreeT (f :: Type -> Type) (m :: Type -> Type) a #

#### Instances

Instances details

(Functor f, Monad m) => MonadFree f (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods wrap :: f (FreeT f m a) -> FreeT f m a
(Functor f, MonadError e m) => MonadError e (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods throwError :: e -> FreeT f m a Source # catchError :: FreeT f m a -> (e -> FreeT f m a) -> FreeT f m a Source #
(Functor f, MonadReader r m) => MonadReader r (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods ask :: FreeT f m r Source # local :: (r -> r) -> FreeT f m a -> FreeT f m a Source # reader :: (r -> a) -> FreeT f m a Source #
(Functor f, MonadState s m) => MonadState s (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods get :: FreeT f m s Source # put :: s -> FreeT f m () Source # state :: (s -> (a, s)) -> FreeT f m a Source #
(Functor f, MonadWriter w m) => MonadWriter w (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods writer :: (a, w) -> FreeT f m a Source # tell :: w -> FreeT f m () Source # listen :: FreeT f m a -> FreeT f m (a, w) Source # pass :: FreeT f m (a, w -> w) -> FreeT f m a Source #
(Functor f, MonadBase b m) => MonadBase b (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftBase :: b α -> FreeT f m α
Functor f => MonadTrans (FreeT f) |
Instance details Defined in Control.Monad.Trans.Free Methods lift :: Monad m => m a -> FreeT f m a Source #
(Functor f, MonadFail m) => MonadFail (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods fail :: String -> FreeT f m a Source #
(Functor f, MonadIO m) => MonadIO (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftIO :: IO a -> FreeT f m a Source #
(Foldable m, Foldable f) => Foldable (FreeT f m) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

fold :: Monoid m0 => FreeT f m m0 -> m0 Source #

foldMap :: Monoid m0 => (a -> m0) -> FreeT f m a -> m0 Source #

foldMap' :: Monoid m0 => (a -> m0) -> FreeT f m a -> m0 Source #

foldr :: (a -> b -> b) -> b -> FreeT f m a -> b Source #

foldr' :: (a -> b -> b) -> b -> FreeT f m a -> b Source #

foldl :: (b -> a -> b) -> b -> FreeT f m a -> b Source #

foldl' :: (b -> a -> b) -> b -> FreeT f m a -> b Source #

foldr1 :: (a -> a -> a) -> FreeT f m a -> a Source #

foldl1 :: (a -> a -> a) -> FreeT f m a -> a Source #

toList :: FreeT f m a -> [a] Source #

null :: FreeT f m a -> Bool Source #

length :: FreeT f m a -> Int Source #

elem :: Eq a => a -> FreeT f m a -> Bool Source #

maximum :: Ord a => FreeT f m a -> a Source #

minimum :: Ord a => FreeT f m a -> a Source #

sum :: Num a => FreeT f m a -> a Source #

product :: Num a => FreeT f m a -> a Source #

(Eq1 f, Eq1 m) => Eq1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftEq :: (a -> b -> Bool) -> FreeT f m a -> FreeT f m b -> Bool Source #
(Ord1 f, Ord1 m) => Ord1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftCompare :: (a -> b -> Ordering) -> FreeT f m a -> FreeT f m b -> Ordering Source #
(Read1 f, Read1 m) => Read1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (FreeT f m a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [FreeT f m a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (FreeT f m a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [FreeT f m a] Source #
(Show1 f, Show1 m) => Show1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> FreeT f m a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [FreeT f m a] -> ShowS Source #
(Monad m, Traversable m, Traversable f) => Traversable (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods traverse :: Applicative f0 => (a -> f0 b) -> FreeT f m a -> f0 (FreeT f m b) Source # sequenceA :: Applicative f0 => FreeT f m (f0 a) -> f0 (FreeT f m a) Source # mapM :: Monad m0 => (a -> m0 b) -> FreeT f m a -> m0 (FreeT f m b) Source # sequence :: Monad m0 => FreeT f m (m0 a) -> m0 (FreeT f m a) Source #
(Functor f, MonadPlus m) => Alternative (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods empty :: FreeT f m a Source # (<|>) :: FreeT f m a -> FreeT f m a -> FreeT f m a Source # some :: FreeT f m a -> FreeT f m [a] Source # many :: FreeT f m a -> FreeT f m [a] Source #
(Functor f, Monad m) => Applicative (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods pure :: a -> FreeT f m a Source # (<*>) :: FreeT f m (a -> b) -> FreeT f m a -> FreeT f m b Source # liftA2 :: (a -> b -> c) -> FreeT f m a -> FreeT f m b -> FreeT f m c Source # (*>) :: FreeT f m a -> FreeT f m b -> FreeT f m b Source # (<*) :: FreeT f m a -> FreeT f m b -> FreeT f m a Source #
(Functor f, Functor m) => Functor (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods fmap :: (a -> b) -> FreeT f m a -> FreeT f m b Source # (<$) :: a -> FreeT f m b -> FreeT f m a Source #
(Functor f, Monad m) => Monad (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods (>>=) :: FreeT f m a -> (a -> FreeT f m b) -> FreeT f m b Source # (>>) :: FreeT f m a -> FreeT f m b -> FreeT f m b Source # return :: a -> FreeT f m a Source #
(Functor f, MonadPlus m) => MonadPlus (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods mzero :: FreeT f m a Source # mplus :: FreeT f m a -> FreeT f m a -> FreeT f m a Source #
(Functor f, MonadCatch m) => MonadCatch (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods catch :: (HasCallStack, Exception e) => FreeT f m a -> (e -> FreeT f m a) -> FreeT f m a Source #
(Functor f, MonadThrow m) => MonadThrow (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods throwM :: (HasCallStack, Exception e) => e -> FreeT f m a Source #
(Functor f, MonadCont m) => MonadCont (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods callCC :: ((a -> FreeT f m b) -> FreeT f m a) -> FreeT f m a Source #
(Functor f, Monad m) => Apply (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods (<.>) :: FreeT f m (a -> b) -> FreeT f m a -> FreeT f m b (.>) :: FreeT f m a -> FreeT f m b -> FreeT f m b (<.) :: FreeT f m a -> FreeT f m b -> FreeT f m a liftF2 :: (a -> b -> c) -> FreeT f m a -> FreeT f m b -> FreeT f m c
(Functor f, Monad m) => Bind (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods (>>-) :: FreeT f m a -> (a -> FreeT f m b) -> FreeT f m b join :: FreeT f m (FreeT f m a) -> FreeT f m a
(Read1 f, Read1 m, Read a) => Read (FreeT f m a) |
Instance details Defined in Control.Monad.Trans.Free Methods readsPrec :: Int -> ReadS (FreeT f m a) Source # readList :: ReadS [FreeT f m a] Source # readPrec :: ReadPrec (FreeT f m a) Source # readListPrec :: ReadPrec [FreeT f m a] Source #
(Show1 f, Show1 m, Show a) => Show (FreeT f m a) |
Instance details Defined in Control.Monad.Trans.Free Methods showsPrec :: Int -> FreeT f m a -> ShowS Source # show :: FreeT f m a -> String Source # showList :: [FreeT f m a] -> ShowS Source #
(Eq1 f, Eq1 m, Eq a) => Eq (FreeT f m a) |
Instance details Defined in Control.Monad.Trans.Free Methods (==) :: FreeT f m a -> FreeT f m a -> Bool Source # (/=) :: FreeT f m a -> FreeT f m a -> Bool Source #
(Ord1 f, Ord1 m, Ord a) => Ord (FreeT f m a) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

compare :: FreeT f m a -> FreeT f m a -> Ordering Source #

(<) :: FreeT f m a -> FreeT f m a -> Bool Source #

(<=) :: FreeT f m a -> FreeT f m a -> Bool Source #

(>) :: FreeT f m a -> FreeT f m a -> Bool Source #

(>=) :: FreeT f m a -> FreeT f m a -> Bool Source #

max :: FreeT f m a -> FreeT f m a -> FreeT f m a Source #

min :: FreeT f m a -> FreeT f m a -> FreeT f m a Source #

concats :: forall (m :: Type -> Type) a x. Monad m => FreeT (Producer a m) m x -> Producer a m x Source #

Join a `FreeT`-delimited stream of `Producer`s into a single `Producer`

    concats :: Monad m => Joiner a m x

intercalates :: forall (m :: Type -> Type) a x. Monad m => Producer a m () -> FreeT (Producer a m) m x -> Producer a m x Source #

Join a `FreeT`-delimited stream of `Producer`s into a single `Producer` by intercalating a `Producer` in between them

    intercalates :: Monad m => Producer a m () -> Joiner a m x

type Parser a (m :: Type -> Type) r = forall x. StateT (Producer a m x) m r Source #

A `Parser` is an action that reads from and writes to a stored `Producer`