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

Modulepretty-simple-4.1.3.0Haskell2010

Text.Pretty.Simple.Internal.Printer

  • 6 types
  • 17 values
Example1 expression
import Text.Pretty.Simple (pPrintString, pPrintStringOpt)
datadata CheckColorTty
#

Determines whether pretty-simple should check if the output Handle is a TTY device. Normally, users only want to print in color if the output Handle is a TTY device.

Constructors

Instances4Eq, Show, Generic, Rep
datadata StringOutputStyle
#

Control how escaped and non-printable are output for strings.

See outputOptionsStringStyle for what the output looks like with each of these options.

Constructors

  • Literal

    Output string literals by printing the source characters exactly.

    For examples: without this option the printer will insert a newline in place of "n", with this options the printer will output \ and n. Similarly the exact escape codes used in the input string will be replicated, so "65" will be printed as "65" and not A.

  • EscapeNonPrintable

    Replace non-printable characters with hexadecimal escape sequences.

  • DoNotEscapeNonPrintable

    Output non-printable characters without modification.

Instances4Eq, Show, Generic, Rep
datadata OutputOptions
#

Data-type wrapping up all the options available when rendering the list of Outputs.

Constructors

  • OutputOptions
    • outputOptionsIndentAmount :: Int

      Number of spaces to use when indenting. It should probably be either 2 or 4.

    • outputOptionsPageWidth :: Int

      The maximum number of characters to fit on to one line.

    • outputOptionsCompact :: Bool

      Use less vertical (and more horizontal) space.

    • outputOptionsCompactParens :: Bool

      Group closing parentheses on to a single line.

    • outputOptionsInitialIndent :: Int

      Indent the whole output by this amount.

    • outputOptionsColorOptions :: Maybe ColorOptions

      If this is Nothing, then don't colorize the output. If this is Just colorOptions, then use colorOptions to colorize the output.

    • outputOptionsStringStyle :: StringOutputStyle

      Controls how string literals are output.

      By default, the pPrint functions escape non-printable characters, but print all printable characters:

      Example1 expression
      pPrintString "\"A \\x42 Ä \\xC4 \\x1 \\n\"""A B Ä Ä \x1"

      Here, you can see that the character A has been printed as-is. x42 has been printed in the non-escaped version, B. The non-printable character x1 has been printed as x1. Newlines will be removed to make the output easier to read.

      This corresponds to the StringOutputStyle called EscapeNonPrintable.

      (Note that in the above and following examples, the characters have to be double-escaped, which makes it somewhat confusing...)

      Another output style is DoNotEscapeNonPrintable. This is similar to EscapeNonPrintable, except that non-printable characters get printed out literally to the screen.

      Example1 expression
      pPrintStringOpt CheckColorTty defaultOutputOptionsDarkBg{ outputOptionsStringStyle = DoNotEscapeNonPrintable } "\"A \\x42 Ä \\xC4 \\n\"""A B Ä Ä"

      If you change the above example to contain x1, you can see that it is output as a literal, non-escaped character. Newlines are still removed for readability.

      Another output style is Literal. This just outputs all escape characters.

      Example1 expression
      pPrintStringOpt CheckColorTty defaultOutputOptionsDarkBg{ outputOptionsStringStyle = Literal } "\"A \\x42 Ä \\xC4 \\x1 \\n\"""A \x42 Ä \xC4 \x1 \n"

      You can see that all the escape characters get output literally, including newline.

Instances4Eq, Show, Generic, Rep
valueisSimple :: Expr -> Bool
#

Determine whether this expression should be displayed on a single line.

datadata Annotation
#

An abstract annotation type, representing the various elements we may want to highlight.

Instances2Eq, Show
  • Eq AnnotationDefined in pretty-simple-4.1.3.0 · Text.Pretty.Simple.Internal.Printer
  • Show AnnotationDefined in pretty-simple-4.1.3.0 · Text.Pretty.Simple.Internal.Printer

Replace non-printable characters with hex escape sequences.

Example1 expression
escapeNonPrintable "\x1\x2""\\x1\\x2"

Newlines will not be escaped.

Example1 expression
escapeNonPrintable "hello\nworld""hello\nworld"

Printable characters will not be escaped.

Example1 expression
escapeNonPrintable "h\101llo""hello"
valueescape :: Char -> ShowS
#

Replace an unprintable character except a newline with a hex escape sequence.

datadata Stream a
#

An infinite list

Constructors

Instances1Show
  • Show a => Show (Stream a)Defined in pretty-simple-4.1.3.0 · Text.Pretty.Simple.Internal.Printer
valuestreamCycle :: NonEmpty a -> Stream a
#

Analogous to cycle While the inferred signature here is more general, it would diverge on an empty structure