HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleturtle-1.6.2Haskell2010

Turtle.Bytes

This module provides ByteString analogs of several utilities in Turtle.Prelude. The main difference is that the chunks of bytes read by these utilities are not necessarily aligned to line boundaries.

Contents
  1. Byte operations
  2. Subprocess management
Synopsis
  • Packageturtle-1.6.2
  • Exports32
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBytes.hs

Byte operations

Read chunks of bytes from standard input

The chunks are not necessarily aligned to line boundaries

valuecompress
  1. :: Int

    Compression level

  2. -> WindowBits
  3. -> Shell ByteString
  4. -> Shell ByteString

Compress a stream using zlib

Note that this can decompress streams that are the concatenation of multiple compressed streams (just like gzip)

Example3 expressions
let compressed = select [ "ABC", "DEF" ] & compress 0 defaultWindowBitscompressed & decompress defaultWindowBits & view"ABCDEF"(compressed <|> compressed) & decompress defaultWindowBits & view"ABCDEF""ABCDEF"
newtypenewtype WindowBits

This specifies the size of the compression window. Larger values of this parameter result in better compression at the expense of higher memory usage.

The compression window size is the value of the the window bits raised to the power 2. The window bits must be in the range 9..15 which corresponds to compression window sizes of 512b to 32Kb. The default is 15 which is also the maximum size.

The total amount of memory used depends on the window bits and the MemoryLevel. See the MemoryLevel for the details.

Constructors

Instances5Eq, Ord, Show, Generic, Rep

Decode a stream of bytes as UTF8 Text

NOTE: This function will throw a pure exception (i.e. an error) if UTF8 decoding fails (mainly due to limitations in the text package's stream decoding API)

Subprocess management

valueproc
  1. :: MonadIO io
  2. => Text

    Command

  3. -> [Text]

    Arguments

  4. -> Shell ByteString

    Chunks of bytes written to process input

  5. -> io ExitCode

    Exit code

Run a command using execvp, retrieving the exit code

The command inherits stdout and stderr for the current process

valueshell
  1. :: MonadIO io
  2. => Text

    Command line

  3. -> Shell ByteString

    Chunks of bytes written to process input

  4. -> io ExitCode

    Exit code

Run a command line using the shell, retrieving the exit code

This command is more powerful than proc, but highly vulnerable to code injection if you template the command line with untrusted input

The command inherits stdout and stderr for the current process

valueinshell
  1. :: Text

    Command line

  2. -> Shell ByteString

    Chunks of bytes written to process input

  3. -> Shell ByteString

    Chunks of bytes read from process output

Run a command line using the shell, streaming stdout as chunks of ByteString

This command is more powerful than inproc, but highly vulnerable to code injection if you template the command line with untrusted input

The command inherits stderr for the current process

valueinshellWithErr
  1. :: Text

    Command line

  2. -> Shell ByteString

    Chunks of bytes written to process input

  3. -> Shell (Either ByteString ByteString)

    Chunks of either output (Right) or error (Left)

Run a command line using the shell, streaming stdout and stderr as chunks of ByteString. Chunks from stdout are wrapped in Right and chunks from stderr are wrapped in Left.

This command is more powerful than inprocWithErr, but highly vulnerable to code injection if you template the command line with untrusted input

Throws an ExitCode exception if the command returns a non-zero exit code

valueshellStrict
  1. :: MonadIO io
  2. => Text

    Command line

  3. -> Shell ByteString

    Chunks of bytes written to process input

  4. -> io (ExitCode, ByteString)

    Exit code and stdout

Run a command line using the shell, retrieving the exit code and stdout as a non-lazy blob of Text

This command is more powerful than proc, but highly vulnerable to code injection if you template the command line with untrusted input

The command inherits stderr for the current process

valueshellStrictWithErr
  1. :: MonadIO io
  2. => Text

    Command line

  3. -> Shell ByteString

    Chunks of bytes written to process input

  4. -> io (ExitCode, ByteString, ByteString)

    (Exit code, stdout, stderr)

Run a command line using the shell, retrieving the exit code, stdout, and stderr as a non-lazy blob of Text

This command is more powerful than proc, but highly vulnerable to code injection if you template the command line with untrusted input