Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Nixfmt.Predoc
Description
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
- 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.
Minimal complete definition
Instances
Pretty String Source # | |
Pretty Text Source # | |
Pretty Doc Source # | |
Pretty Token Source # | |
Pretty File Source # | |
Pretty Expression Source # | |
Defined in Nixfmt.Pretty Methods pretty :: Expression -> Doc Source # | |
Pretty Parameter Source # | |
Pretty ParamAttr Source # | |
Pretty Term Source # | |
Pretty Binder Source # | |
Pretty Selector Source # | |
Pretty SimpleSelector Source # | |
Defined in Nixfmt.Pretty Methods pretty :: SimpleSelector -> Doc Source # | |
Pretty StringPart Source # | |
Defined in Nixfmt.Pretty Methods pretty :: StringPart -> Doc Source # | |
Pretty TrailingComment Source # | |
Defined in Nixfmt.Pretty Methods pretty :: TrailingComment -> Doc Source # | |
Pretty Trivium Source # | |
Pretty [[StringPart]] Source # | |
Defined in Nixfmt.Pretty Methods pretty :: [[StringPart]] -> Doc Source # | |
Pretty [Token] Source # | |
Pretty [StringPart] Source # | |
Defined in Nixfmt.Pretty Methods pretty :: [StringPart] -> Doc Source # | |
Pretty [Trivium] Source # | |
Pretty a => Pretty (Maybe a) Source # | |
Pretty a => Pretty (Ann a) 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.