HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

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.

  • 1 type
  • 31 values
  • Packageturtle-1.6.2
  • Exports32
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBytes.hs

Byte operations

15 declarations
valuestdin :: Shell ByteString
#

Read chunks of bytes from standard input

The chunks are not necessarily aligned to line boundaries

valuestdout :: MonadIO io => Shell ByteString -> io ()
#

Stream chunks of bytes to standard output

The chunks are not necessarily aligned to line boundaries

valuestderr :: MonadIO io => Shell ByteString -> io ()
#

Stream chunks of bytes to standard error

The chunks do not need to be 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

17 declarations
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

valueinproc
  1. :: Text

    Command

  2. -> [Text]

    Arguments

  3. -> Shell ByteString

    Chunks of bytes written to process input

  4. -> Shell ByteString

    Chunks of bytes read from process output

#

Run a command using execvp, streaming stdout as chunks of ByteString

The command inherits 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

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

    Command

  3. -> [Text]

    Arguments

  4. -> Shell ByteString

    Chunks of bytes written to process input

  5. -> io (ExitCode, ByteString)

    Exit code and stdout

#

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

The command inherits stderr for the current process

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

valuestream
  1. :: CreateProcess

    Command

  2. -> Shell ByteString

    Chunks of bytes written to process input

  3. -> Shell ByteString

    Chunks of bytes read from process output

#

stream generalizes inproc and inshell by allowing you to supply your own custom CreateProcess. This is for advanced users who feel comfortable using the lower-level process API

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