Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module implements a layer around the prettyprinter package, making it easier to use.
Synopsis
- text :: Text -> Doc
- sepBy :: Pretty a => Doc -> [a] -> Doc
- hcat :: Pretty a => [a] -> Doc
- base :: Doc -> Doc
- group :: Pretty a => a -> Doc
- nest :: Int -> Doc -> Doc
- softline' :: Doc
- line' :: Doc
- softline :: Doc
- line :: Doc
- hardspace :: Doc
- hardline :: Doc
- emptyline :: Doc
- newline :: Doc
- data DocE
- type Doc = [DocE]
- class Pretty a
- pretty :: Pretty a => a -> Doc
- fixup :: Doc -> Doc
- layout :: Pretty a => Int -> a -> Text
- textWidth :: Text -> Int
Documentation
nest :: Int -> Doc -> Doc Source #
nest n doc
sets the indentation for lines in doc
to n
more than the
indentation of the part before it. This is based on the actual indentation of
the line, rather than the indentation it should have used: If multiple
indentation levels start on the same line, only the last indentation level
will be applied on the next line. This prevents unnecessary nesting.
Single document element. Documents are modeled as lists of these elements in order to make concatenation simple.
Instances
Pretty Doc Source # | |
Pretty Binder Source # | |
Pretty Expression Source # | |
Defined in Nixfmt.Pretty pretty :: Expression -> Doc Source # | |
Pretty File Source # | |
Pretty ParamAttr Source # | |
Pretty Parameter Source # | |
Pretty Selector Source # | |
Pretty SimpleSelector Source # | |
Defined in Nixfmt.Pretty pretty :: SimpleSelector -> Doc Source # | |
Pretty StringPart Source # | |
Defined in Nixfmt.Pretty pretty :: StringPart -> Doc Source # | |
Pretty Term Source # | |
Pretty Token Source # | |
Pretty TrailingComment Source # | |
Defined in Nixfmt.Pretty pretty :: TrailingComment -> Doc Source # | |
Pretty Trivium Source # | |
Pretty Text Source # | |
Pretty String Source # | |
Pretty a => Pretty (Ann a) Source # | |
Pretty a => Pretty (Maybe a) Source # | |
Pretty [StringPart] Source # | |
Defined in Nixfmt.Pretty pretty :: [StringPart] -> Doc Source # | |
Pretty [Token] Source # | |
Pretty [Trivium] Source # | |
Pretty [[StringPart]] Source # | |
Defined in Nixfmt.Pretty pretty :: [[StringPart]] -> Doc Source # |
Fix up a Doc in multiple stages: - First, all spacings are moved out of Groups and Nests and empty Groups and Nests are removed. - Now, all consecutive Spacings are ensured to be in the same list, so each sequence of Spacings can be merged into a single one. - Finally, Spacings right before a Nest should be moved inside in order to get the right indentation.