clash-lib-1.8.1: Clash: a functional hardware description language - As a library

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Text.Prettyprint.Doc.Extra

Contents

- Orphan instances

Synopsis

- type Doc = Doc ()
- pretty :: (Applicative f, Pretty a) => a -> f Doc
- string :: Applicative f => Text -> f Doc
- comma :: Applicative f => f Doc
- colon :: Applicative f => f Doc
- int :: Applicative f => Int -> f Doc
- integer :: Applicative f => Integer -> f Doc
- char :: Applicative f => Char -> f Doc
- space :: Applicative f => f Doc
- fill :: Applicative f => Int -> f Doc -> f Doc
- parens :: Functor f => f Doc -> f Doc
- (<+>) :: Applicative f => f Doc -> f Doc -> f Doc
- isEmpty :: Doc -> Bool
- semi :: Applicative f => f Doc
- equals :: Applicative f => f Doc
- lparen :: Applicative f => f Doc
- rparen :: Applicative f => f Doc
- lbrace :: Applicative f => f Doc
- rbrace :: Applicative f => f Doc
- squotes :: Applicative f => f Doc -> f Doc
- brackets :: Functor f => f Doc -> f Doc
- braces :: Functor f => f Doc -> f Doc
- hcat :: Functor f => f [Doc] -> f Doc
- hsep :: Functor f => f [Doc] -> f Doc
- vcat :: Functor f => f [Doc] -> f Doc
- nest :: Functor f => Int -> f Doc -> f Doc
- punctuate :: Applicative f => f Doc -> f [Doc] -> f [Doc]
- line :: Applicative f => f Doc
- dot :: Applicative f => f Doc
- comment :: Applicative f => Text -> Text -> f Doc
- indent :: Functor f => Int -> f Doc -> f Doc
- emptyDoc :: Applicative f => f Doc
- line' :: Applicative f => f Doc
- softline :: Applicative f => f Doc
- softline' :: Applicative f => f Doc
- flatAlt :: Applicative f => f Doc -> f Doc -> f Doc
- align :: Functor f => f Doc -> f Doc
- encloseSep :: Applicative f => f Doc -> f Doc -> f Doc -> f [Doc] -> f Doc
- tupled :: Functor f => f [Doc] -> f Doc
- vsep :: Functor f => f [Doc] -> f Doc
- column :: Functor f => f (Int -> Doc) -> f Doc
- nesting :: Functor f => f (Int -> Doc) -> f Doc
- enclose :: Applicative f => f Doc -> f Doc -> f Doc -> f Doc
- dquotes :: Functor f => f Doc -> f Doc
- squote :: Applicative f => f Doc
- renderOneLine :: Doc ann -> Text
- layoutOneLine :: Doc ann -> SimpleDocStream ann
- stringS :: Applicative f => Text -> f Doc
- newtype LayoutOptions = LayoutOptions {
  - layoutPageWidth :: PageWidth
  }
- data PageWidth
  - = AvailablePerLine !Int !Double
  - | Unbounded
- layoutCompact :: Doc ann1 -> SimpleDocStream ann2
- layoutPretty :: LayoutOptions -> Doc ann -> SimpleDocStream ann
- renderLazy :: SimpleDocStream ann -> Text

# Documentation

type Doc = Doc () Source #

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

string :: Applicative f => Text -> f Doc Source #

comma :: Applicative f => f Doc Source #

colon :: Applicative f => f Doc Source #

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

integer :: Applicative f => Integer -> f Doc Source #

char :: Applicative f => Char -> f Doc Source #

space :: Applicative f => f Doc Source #

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

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

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

isEmpty :: Doc -> Bool Source #

semi :: Applicative f => f Doc Source #

equals :: Applicative f => f Doc Source #

lparen :: Applicative f => f Doc Source #

rparen :: Applicative f => f Doc Source #

lbrace :: Applicative f => f Doc Source #

rbrace :: Applicative f => f Doc Source #

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

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

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

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

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

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

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

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

line :: Applicative f => f Doc Source #

dot :: Applicative f => f Doc Source #

comment :: Applicative f => Text -> Text -> f Doc Source #

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

emptyDoc :: Applicative f => f Doc Source #

line' :: Applicative f => f Doc Source #

softline :: Applicative f => f Doc Source #

softline' :: Applicative f => f Doc Source #

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

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

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

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

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

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

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

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

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

squote :: Applicative f => f Doc Source #

renderOneLine :: Doc ann -> Text Source #

layoutOneLine :: Doc ann -> SimpleDocStream ann Source #

stringS :: Applicative f => Text -> f Doc Source #

newtype LayoutOptions Source #

Options to influence the layout algorithms.

Constructors

LayoutOptions |

Fields

- layoutPageWidth :: PageWidth

#### Instances

Instances details

Show LayoutOptions |
Instance details Defined in Prettyprinter.Internal Methods showsPrec :: Int -> LayoutOptions -> ShowS Source # show :: LayoutOptions -> String Source # showList :: [LayoutOptions] -> ShowS Source #
Eq LayoutOptions |
Instance details Defined in Prettyprinter.Internal Methods (==) :: LayoutOptions -> LayoutOptions -> Bool Source # (/=) :: LayoutOptions -> LayoutOptions -> Bool Source #
Ord LayoutOptions |

Instance details

Defined in Prettyprinter.Internal

Methods

compare :: LayoutOptions -> LayoutOptions -> Ordering Source #

(<) :: LayoutOptions -> LayoutOptions -> Bool Source #

(<=) :: LayoutOptions -> LayoutOptions -> Bool Source #

(>) :: LayoutOptions -> LayoutOptions -> Bool Source #

(>=) :: LayoutOptions -> LayoutOptions -> Bool Source #

max :: LayoutOptions -> LayoutOptions -> LayoutOptions Source #

min :: LayoutOptions -> LayoutOptions -> LayoutOptions Source #

data PageWidth Source #

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.

#### Instances

Instances details

Show PageWidth |
Instance details Defined in Prettyprinter.Internal Methods showsPrec :: Int -> PageWidth -> ShowS Source # show :: PageWidth -> String Source # showList :: [PageWidth] -> ShowS Source #
Eq PageWidth |
Instance details Defined in Prettyprinter.Internal Methods (==) :: PageWidth -> PageWidth -> Bool Source # (/=) :: PageWidth -> PageWidth -> Bool Source #
Ord PageWidth |

Instance details

Defined in Prettyprinter.Internal

Methods

compare :: PageWidth -> PageWidth -> Ordering Source #

(<) :: PageWidth -> PageWidth -> Bool Source #

(<=) :: PageWidth -> PageWidth -> Bool Source #

(>) :: PageWidth -> PageWidth -> Bool Source #

(>=) :: PageWidth -> PageWidth -> Bool Source #

max :: PageWidth -> PageWidth -> PageWidth Source #

min :: PageWidth -> PageWidth -> PageWidth Source #

layoutCompact :: Doc ann1 -> SimpleDocStream ann2 Source #

`(layoutCompact x)` lays out the document `x` without adding any indentation and without preserving annotations. 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 Source #

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 Source #

`(`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 Source #