machines-bytestring-0.1.0.0: ByteString support for machines

Safe HaskellNone
LanguageHaskell2010

Data.Machine.ByteString

Contents

Synopsis

Sources

fromLazy :: ByteString -> Source ByteString Source #

Transform a lazy ByteString into a Source of strict ByteString.

fromStrict :: ByteString -> Source ByteString Source #

Use a strict ByteString as Source

fromHandle :: MonadIO m => Handle -> SourceT m ByteString Source #

Use an Handle to create a Source of strict ByteString.

hGet :: MonadIO m => Int -> Handle -> SourceT m ByteString Source #

Read chunks of strict ByteString of fixed size.

hGetSome :: MonadIO m => Int -> Handle -> SourceT m ByteString Source #

Like hGet but may be returned smaller chunks if there are not enough data immediately available.

hGetNonBlocking :: MonadIO m => Int -> Handle -> SourceT m ByteString Source #

Similar to hGet but it will never block waiting for data.

Sinks

stdin :: MonadIO m => SourceT m ByteString Source #

Source that stream bytes from stdin

stdout :: MonadIO m => MachineT m (Is ByteString) () Source #

Stream data to stdout

stderr :: MonadIO m => MachineT m (Is ByteString) () Source #

Stream data to stderr

toHandle :: MonadIO m => Handle -> MachineT m (Is ByteString) () Source #

Create a Machine that stream its input to the given Handle

interact :: Process ByteString ByteString -> IO () Source #

Use a Process ByteString ByteString to transform the input from stdin and output to stdout

Processes

mapping :: (Word8 -> Word8) -> Process ByteString ByteString Source #

Transform every byte of a ByteString

filtered :: (Word8 -> Bool) -> Process ByteString ByteString Source #

Allow to pass only the bytes that satisfy the predicate

taking :: Integral n => n -> Process ByteString ByteString Source #

Stream only the first n bytes

takingWhile :: (Word8 -> Bool) -> Process ByteString ByteString Source #

Stream bytes until they fail the predicate

scan :: (Word8 -> Word8 -> Word8) -> Word8 -> Process ByteString ByteString Source #

Strict left scan over the bytes

pack :: Process Word8 ByteString Source #

Convert a stream of Bytes into a stream of strict ByteString of size equal to defaultChunkSize

unpack :: Process ByteString Word8 Source #

Convert a stream of strict ByteString into a stream of Bytes