Copyright | (c) Niklas Broberg 2004-2009 (c) The GHC Team Noel Winstanley 1997-2000 |
---|---|
License | BSD-style (see the file LICENSE.txt) |
Maintainer | Niklas Broberg, d00nibro@chalmers.se |
Stability | stable |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
Pretty printer for Haskell with extensions.
Synopsis
- class Pretty a
- prettyPrintStyleMode :: Pretty a => Style -> PPHsMode -> a -> String
- prettyPrintWithMode :: Pretty a => PPHsMode -> a -> String
- prettyPrint :: Pretty a => a -> String
- data Style = Style {
- mode :: Mode
- lineLength :: Int
- ribbonsPerLine :: Float
- style :: Style
- data Mode
- data PPHsMode = PPHsMode {
- classIndent :: Indent
- doIndent :: Indent
- multiIfIndent :: Indent
- caseIndent :: Indent
- letIndent :: Indent
- whereIndent :: Indent
- onsideIndent :: Indent
- spacing :: Bool
- layout :: PPLayout
- linePragmas :: Bool
- type Indent = Int
- data PPLayout
- defaultMode :: PPHsMode
- prettyPrim :: Pretty a => a -> Doc
- prettyPrimWithMode :: Pretty a => PPHsMode -> a -> Doc
Pretty printing
Things that can be pretty-printed, including all the syntactic objects in Language.Haskell.Exts.Syntax.
Instances
prettyPrintStyleMode :: Pretty a => Style -> PPHsMode -> a -> String Source #
render the document with a given mode. renderWithMode :: PPHsMode -> Doc -> String renderWithMode = renderStyleMode P.style
render the document with defaultMode
.
render :: Doc -> String
render = renderWithMode defaultMode
pretty-print with a given style and mode.
prettyPrintWithMode :: Pretty a => PPHsMode -> a -> String Source #
pretty-print with the default style and a given mode.
prettyPrint :: Pretty a => a -> String Source #
pretty-print with the default style and defaultMode
.
Pretty-printing styles (from Text.PrettyPrint.HughesPJ)
A rendering style. Allows us to specify constraints to choose among the many different rendering options.
Style | |
|
Instances
Eq Style | |
Show Style | |
Generic Style | |
type Rep Style | |
Defined in Text.PrettyPrint.Annotated.HughesPJ type Rep Style = D1 (MetaData "Style" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6" False) (C1 (MetaCons "Style" PrefixI True) (S1 (MetaSel (Just "mode") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Mode) :*: (S1 (MetaSel (Just "lineLength") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int) :*: S1 (MetaSel (Just "ribbonsPerLine") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Float)))) |
Rendering mode.
PageMode | Normal rendering ( |
ZigZagMode | With zig-zag cuts. |
LeftMode | No indentation, infinitely long lines ( |
OneLineMode | All on one line, |
Instances
Eq Mode | |
Show Mode | |
Generic Mode | |
type Rep Mode | |
Defined in Text.PrettyPrint.Annotated.HughesPJ type Rep Mode = D1 (MetaData "Mode" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6" False) ((C1 (MetaCons "PageMode" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "ZigZagMode" PrefixI False) (U1 :: * -> *)) :+: (C1 (MetaCons "LeftMode" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "OneLineMode" PrefixI False) (U1 :: * -> *))) |
Haskell formatting modes
Pretty-printing parameters.
Note: the onsideIndent
must be positive and less than all other indents.
PPHsMode | |
|
Varieties of layout we can use.
PPOffsideRule | classical layout |
PPSemiColon | classical layout made explicit |
PPInLine | inline decls, with newlines between them |
PPNoLayout | everything on a single line |
defaultMode :: PPHsMode Source #
The default mode: pretty-print using the offside rule and sensible defaults.
Primitive Printers
prettyPrim :: Pretty a => a -> Doc Source #
pretty-print with the default style and defaultMode
.