HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduledistribution-nixpkgs-1.7.1.1Haskell2010

Language.Nix.PrettyPrinting

Internal pretty-printing helpers for Nix expressions.

  • 5 types
  • 1 class
  • 66 values

Re-exports from other modules

62 declarations
valuetext :: String -> Doc
#

A document of height 1 containing a literal string. text satisfies the following laws:

The side condition on the last law is necessary because text "" has height 1, while empty has no height.

classclass Pretty a where
#

Pretty printing class. The precedence level is used in a similar way as in the Show class. Minimal complete definition is either pPrintPrec or pPrint.

Methods

Instances24Pretty, …
newtypenewtype Doc
#

The abstract type of documents. A Doc represents a set of layouts. A Doc with no occurrences of Union or NoDoc represents just one layout.

Instances10Eq, Show, IsString, Generic, Semigroup, Monoid, …
value(<+>) :: Doc -> Doc -> Doc
#

Beside, separated by space, unless one of the arguments is empty. <+> is associative, with identity empty.

valuechar :: Char -> Doc
#

A document of height and width 1, containing a literal character.

datadata TextDetails
#

A TextDetails represents a fragment of text that will be output at some point in a Doc.

Constructors

  • Chr !Char

    A single Char fragment

  • Str String

    A whole String fragment

  • PStr String

    Used to represent a Fast String fragment but now deprecated and identical to the Str constructor.

Instances5Eq, Show, Generic, NFData, Rep
datadata Mode
#

Rendering mode.

Constructors

Instances4Eq, Show, Generic, Rep
datadata Style
#

A rendering style. Allows us to specify constraints to choose among the many different rendering options.

Constructors

  • Style
    • mode :: Mode

      The rendering mode.

    • lineLength :: Int

      Maximum length of a line, in characters.

    • ribbonsPerLine :: Float

      Ratio of line length to ribbon length. A ribbon refers to the characters on a line excluding indentation. So a lineLength of 100, with a ribbonsPerLine of 2.0 would only allow up to 50 characters of ribbon to be displayed on a line, while allowing it to be indented up to 50 characters.

Instances4Eq, Show, Generic, Rep
valuestyle :: Style
#

The default style (mode=PageMode, lineLength=100, ribbonsPerLine=1.5).

value($$) :: Doc -> Doc -> Doc
#

Above, except that if the last line of the first argument stops at least one position before the first line of the second begins, these two lines are overlapped. For example:

   text "hi" $$ nest 5 (text "there")

lays out as

   hi   there

rather than

   hi
        there

$$ is associative, with identity empty, and also satisfies

  • (x $$ y) <> z = x $$ (y <> z), if y non-empty.

value($+$) :: Doc -> Doc -> Doc
#

Above, with no overlapping. $+$ is associative, with identity empty.

valuefirst :: Doc -> Doc -> Doc
#

first returns its first argument if it is non-empty, otherwise its second.

valuefullRender
  1. :: Mode

    Rendering mode.

  2. -> Int

    Line length.

  3. -> Float

    Ribbons per line.

  4. -> (TextDetails -> a -> a)

    What to do with text.

  5. -> a

    What to do at the end.

  6. -> Doc

    The document.

  7. -> a

    Result.

#

The general rendering interface. Please refer to the Style and Mode types for a description of rendering mode, line length and ribbons.

valueptext :: String -> Doc
#

Same as text. Used to be used for Bytestrings.

valuepunctuate :: Doc -> [Doc] -> [Doc]
#
punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn]
valuereduceDoc :: Doc -> RDoc
#

Perform some simplification of a built up GDoc.

valuezeroWidthText :: String -> Doc
#

Some text, but without any width. Use for non-printing text such as a HTML or Latex tags

newtypenewtype PrettyLevel
#

Level of detail in the pretty printed output. Level 0 is the least detail.

Constructors

Instances3Eq, Ord, Show
  • Eq PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Ord PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Show PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass