clash-lib-1.2.2: CAES Language for Synchronous Hardware - As a Library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Text.Prettyprint.Doc.Extra

Synopsis

Documentation

type Doc = Doc () Source #

int :: Applicative f => Int -> f Doc Source #

brackets :: Functor f => f Doc -> f Doc Source #

braces :: Functor f => f Doc -> f Doc Source #

tupled :: Functor f => f [Doc] -> f Doc Source #

(<+>) :: Applicative f => f Doc -> f Doc -> f Doc infixr 6 Source #

vcat :: Functor f => f [Doc] -> f Doc Source #

hcat :: Functor f => f [Doc] -> f Doc Source #

nest :: Functor f => Int -> f Doc -> f Doc Source #

indent :: Functor f => Int -> f Doc -> f Doc Source #

parens :: Functor f => f Doc -> f Doc Source #

punctuate :: Applicative f => f Doc -> f [Doc] -> f [Doc] Source #

encloseSep :: Applicative f => f Doc -> f Doc -> f Doc -> f [Doc] -> f Doc Source #

pretty :: (Applicative f, Pretty a) => a -> f Doc Source #

dquotes :: Functor f => f Doc -> f Doc Source #

align :: Functor f => f Doc -> f Doc Source #

hsep :: Functor f => f [Doc] -> f Doc Source #

vsep :: Functor f => f [Doc] -> f Doc Source #

fill :: Applicative f => Int -> f Doc -> f Doc Source #

column :: Functor f => f (Int -> Doc) -> f Doc Source #

nesting :: Functor f => f (Int -> Doc) -> f Doc Source #

flatAlt :: Applicative f => f Doc -> f Doc -> f Doc Source #

data PageWidth #

Maximum number of characters that fit in one line. The layout algorithms will try not to exceed the set limit by inserting line breaks when applicable (e.g. via softline').

Constructors

AvailablePerLine Int Double

Layouters should not exceed the specified space per line.

  • The Int is the number of characters, including whitespace, that fit in a line. A typical value is 80.
  • The Double is the ribbon with, i.e. the fraction of the total page width that can be printed on. This allows limiting the length of printable text per line. Values must be between 0 and 1, and 0.4 to 1 is typical.
Unbounded

Layouters should not introduce line breaks on their own.

layoutCompact :: Doc ann -> SimpleDocStream ann #

(layoutCompact x) lays out the document x without adding any indentation. Since no 'pretty' printing is involved, this layouter is very fast. The resulting output contains fewer characters than a prettyprinted version and can be used for output that is read by other programs.

>>> let doc = hang 4 (vsep ["lorem", "ipsum", hang 4 (vsep ["dolor", "sit"])])
>>> doc
lorem
    ipsum
    dolor
        sit
>>> let putDocCompact = renderIO System.IO.stdout . layoutCompact
>>> putDocCompact doc
lorem
ipsum
dolor
sit

layoutPretty :: LayoutOptions -> Doc ann -> SimpleDocStream ann #

This is the default layout algorithm, and it is used by show, putDoc and hPutDoc.

layoutPretty commits to rendering something in a certain way if the next element fits the layout constraints; in other words, it has one SimpleDocStream element lookahead when rendering. Consider using the smarter, but a bit less performant, layoutSmart algorithm if the results seem to run off to the right before having lots of line breaks.

renderLazy :: SimpleDocStream ann -> Text #

(renderLazy sdoc) takes the output sdoc from a rendering function and transforms it to lazy text.

>>> let render = TL.putStrLn . renderLazy . layoutPretty defaultLayoutOptions
>>> let doc = "lorem" <+> align (vsep ["ipsum dolor", parens "foo bar", "sit amet"])
>>> render doc
lorem ipsum dolor
      (foo bar)
      sit amet

Orphan instances

Applicative f => IsString (f Doc) Source # 
Instance details

Methods

fromString :: String -> f Doc #