Community
Modules 28

Prettyprinter.Internal.Debug

Warning: internal module! This means that the API may change arbitrarily between versions without notice. Depending on this module may lead to unexpected breakages, so proceed with caution!

This module provides debugging helpers for inspecting Docs.

Use the pretty-simple package to get a nicer layout for shown Diags:

> Text.Pretty.Simple.pPrintNoColor . diag $ align (vcat ["foo", "bar"])
Column
   [
       ( 10
       , Nesting
           [
               ( 10
               , Cat ( Text 3 "foo" )
                   ( Cat ( FlatAlt Line Empty ) ( Text 3 "bar" ) )
               )
           ]
       )
   ]

data Diag ann

A variant of Doc for debugging.

Unlike in the Doc type, the Column, WithPageWidth and Nesting constructors don't contain functions but are "sampled" to allow simple inspection with show.

Char :: Char -> Diag ann

Text :: Int -> Text -> Diag ann

FlatAlt :: (Diag ann) -> (Diag ann) -> Diag ann

Cat :: (Diag ann) -> (Diag ann) -> Diag ann

Nest :: Int -> (Diag ann) -> Diag ann

Union :: (Diag ann) -> (Diag ann) -> Diag ann

Column :: [(Int, Diag ann)] -> Diag ann

[(Int, Diag ann)]

Doc: (Int -> Diag ann)

WithPageWidth :: [(PageWidth, Diag ann)] -> Diag ann

[(PageWidth, Diag ann)]

Doc: (PageWidth -> Diag ann)

Nesting :: [(Int, Diag ann)] -> Diag ann

[(Int, Diag ann)]

Doc: (Int -> Diag ann)

diag :: Doc ann -> Diag ann

Convert a Doc to its diagnostic representation.

The functions in the Column, WithPageWidth and Nesting constructors are sampled with some default values.

Use `diag'` to control the function inputs yourself.

>>> diag $ Doc.align (Doc.vcat ["foo", "bar"])
Column [(10,Nesting [(10,Cat (Text 3 "foo") (Cat (FlatAlt Line Empty) (Text 3 "bar")))])]

diag' :: [Int] -> [PageWidth] -> [Int] -> Doc ann -> Diag ann

[Int]

Cursor positions for the Column constructor

[PageWidth]

For WithPageWidth

[Int]

Nesting levels for Nesting

Instances

1
  • instance Show ann => Show (Diag ann)
Build record and source files

Community contribution. The service has not verified this documentation. The generator reported 21 diagnostics.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-858b1951-web-1

Metadata snapshot: 19f659e0fd2a9606431ae6a3ec65f9ace725052e19ca6a9f9e9f2759e30fd129

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.