Community
Modules 28

Prettyprinter.Util

Frequently useful definitions for working with general prettyprinters.

putDocW :: Int -> Doc ann -> IO ()

Render a document with a certain width. Useful for quick-and-dirty testing of layout behaviour. Used heavily in the doctests of this package, for example.

>>> let doc = reflow "Lorem ipsum dolor sit amet, consectetur adipisicing elit"
>>> putDocW 20 doc
Lorem ipsum dolor
sit amet,
consectetur
adipisicing elit
>>> putDocW 30 doc
Lorem ipsum dolor sit amet,
consectetur adipisicing elit

reflow :: Text -> Doc ann

Insert soft linebreaks between words, so that text is broken into multiple lines when it exceeds the available width.

>>> putDocW 32 (reflow "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
Lorem ipsum dolor sit amet,
consectetur adipisicing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna
aliqua.
'reflow' = 'fillSep' . 'words'

words :: Text -> [Doc ann]

Split an input into word-sized Docs.

>>> putDoc (tupled (words "Lorem ipsum dolor"))
(Lorem, ipsum, dolor)
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.