haskell-src-exts-1.23.1: Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
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-Inferred
Language Haskell98

Language.Haskell.Exts.Pretty

Description

Pretty printer for Haskell with extensions.

Synopsis

Pretty printing

class Pretty a Source #

Things that can be pretty-printed, including all the syntactic objects in Language.Haskell.Exts.Syntax .

Instances

Instances details
Pretty SrcSpan Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty SrcLoc Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty Tool Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Tool -> Doc

prettyPrec :: Int -> Tool -> Doc

Pretty ( Alt l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Alt l -> Doc

prettyPrec :: Int -> Alt l -> Doc

Pretty ( FieldUpdate l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( QualStmt l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: QualStmt l -> Doc

prettyPrec :: Int -> QualStmt l -> Doc

Pretty ( Stmt l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Stmt l -> Doc

prettyPrec :: Int -> Stmt l -> Doc

Pretty ( PatField l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: PatField l -> Doc

prettyPrec :: Int -> PatField l -> Doc

Pretty ( RPat l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: RPat l -> Doc

prettyPrec :: Int -> RPat l -> Doc

Pretty ( RPatOp l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: RPatOp l -> Doc

prettyPrec :: Int -> RPatOp l -> Doc

Pretty ( PXAttr l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: PXAttr l -> Doc

prettyPrec :: Int -> PXAttr l -> Doc

Pretty ( Pat l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Pat l -> Doc

prettyPrec :: Int -> Pat l -> Doc

Pretty ( RuleVar l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: RuleVar l -> Doc

prettyPrec :: Int -> RuleVar l -> Doc

Pretty ( Rule l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Rule l -> Doc

prettyPrec :: Int -> Rule l -> Doc

Pretty ( Activation l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Overlap l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Overlap l -> Doc

prettyPrec :: Int -> Overlap l -> Doc

Pretty ( ModulePragma l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( CallConv l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: CallConv l -> Doc

prettyPrec :: Int -> CallConv l -> Doc

Pretty ( Safety l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Safety l -> Doc

prettyPrec :: Int -> Safety l -> Doc

Pretty ( Splice l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Splice l -> Doc

prettyPrec :: Int -> Splice l -> Doc

Pretty ( Bracket l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Bracket l -> Doc

prettyPrec :: Int -> Bracket l -> Doc

Pretty ( XAttr l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: XAttr l -> Doc

prettyPrec :: Int -> XAttr l -> Doc

Pretty ( XName l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: XName l -> Doc

prettyPrec :: Int -> XName l -> Doc

Pretty ( Exp l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Exp l -> Doc

prettyPrec :: Int -> Exp l -> Doc

Pretty ( Literal l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Literal l -> Doc

prettyPrec :: Int -> Literal l -> Doc

Pretty ( Asst l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Asst l -> Doc

prettyPrec :: Int -> Asst l -> Doc

Pretty ( Context l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Context l -> Doc

prettyPrec :: Int -> Context l -> Doc

Pretty ( FunDep l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: FunDep l -> Doc

prettyPrec :: Int -> FunDep l -> Doc

Pretty ( TyVarBind l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Promoted l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Promoted l -> Doc

prettyPrec :: Int -> Promoted l -> Doc

Pretty ( MaybePromotedName l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Type l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Type l -> Doc

prettyPrec :: Int -> Type l -> Doc

Pretty ( GuardedRhs l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Rhs l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Rhs l -> Doc

prettyPrec :: Int -> Rhs l -> Doc

Pretty ( Unpackedness l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( BangType l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: BangType l -> Doc

prettyPrec :: Int -> BangType l -> Doc

Pretty ( InstDecl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: InstDecl l -> Doc

prettyPrec :: Int -> InstDecl l -> Doc

Pretty ( ClassDecl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( GadtDecl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: GadtDecl l -> Doc

prettyPrec :: Int -> GadtDecl l -> Doc

Pretty ( FieldDecl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( ConDecl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: ConDecl l -> Doc

prettyPrec :: Int -> ConDecl l -> Doc

Pretty ( QualConDecl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Match l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Match l -> Doc

prettyPrec :: Int -> Match l -> Doc

Pretty ( IPBind l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: IPBind l -> Doc

prettyPrec :: Int -> IPBind l -> Doc

Pretty ( DerivStrategy l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Deriving l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Deriving l -> Doc

prettyPrec :: Int -> Deriving l -> Doc

Pretty ( InstHead l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: InstHead l -> Doc

prettyPrec :: Int -> InstHead l -> Doc

Pretty ( InstRule l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: InstRule l -> Doc

prettyPrec :: Int -> InstRule l -> Doc

Pretty ( DeclHead l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: DeclHead l -> Doc

prettyPrec :: Int -> DeclHead l -> Doc

Pretty ( ResultSig l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( InjectivityInfo l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( DataOrNew l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Role l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Role l -> Doc

prettyPrec :: Int -> Role l -> Doc

Pretty ( BooleanFormula l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Annotation l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( TypeEqn l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: TypeEqn l -> Doc

prettyPrec :: Int -> TypeEqn l -> Doc

Pretty ( Decl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Decl l -> Doc

prettyPrec :: Int -> Decl l -> Doc

Pretty ( Assoc l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Assoc l -> Doc

prettyPrec :: Int -> Assoc l -> Doc

Pretty ( ImportSpec l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( ImportSpecList l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( ImportDecl l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Namespace l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( ExportSpec l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( ExportSpecList l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( ModuleHead l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( Module pos) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Module pos -> Doc

prettyPrec :: Int -> Module pos -> Doc

Pretty ( CName l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: CName l -> Doc

prettyPrec :: Int -> CName l -> Doc

Pretty ( Op l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Op l -> Doc

prettyPrec :: Int -> Op l -> Doc

Pretty ( QOp l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: QOp l -> Doc

prettyPrec :: Int -> QOp l -> Doc

Pretty ( IPName l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: IPName l -> Doc

prettyPrec :: Int -> IPName l -> Doc

Pretty ( Name l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: Name l -> Doc

prettyPrec :: Int -> Name l -> Doc

Pretty ( QName l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Methods

pretty :: QName l -> Doc

prettyPrec :: Int -> QName l -> Doc

Pretty ( SpecialCon l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

Pretty ( ModuleName l) Source #
Instance details

Defined in Language.Haskell.Exts.Pretty

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 )

data Style Source #

A rendering style. Allows us to specify constraints to choose among the many different rendering options.

Constructors

Style

Fields

  • mode :: Mode

    The rendering mode.

  • lineLength :: Int

    Maximum length of a line, in characters.

  • ribbonsPerLine :: Float

    Ratio of line length to ribbon length. A ribbon refers to the characters on a line excluding indentation. So a lineLength of 100, with a ribbonsPerLine of 2.0 would only allow up to 50 characters of ribbon to be displayed on a line, while allowing it to be indented up to 50 characters.

style :: Style Source #

The default style ( mode=PageMode, lineLength=100, ribbonsPerLine=1.5 ).

data Mode Source #

Rendering mode.

Constructors

PageMode

Normal rendering ( lineLength and ribbonsPerLine respected').

ZigZagMode

With zig-zag cuts.

LeftMode

No indentation, infinitely long lines ( lineLength ignored), but explicit new lines, i.e., text "one" $$ text "two" , are respected.

OneLineMode

All on one line, lineLength ignored and explicit new lines ( $$ ) are turned into spaces.

Haskell formatting modes

data PPHsMode Source #

Pretty-printing parameters.

Note: the onsideIndent must be positive and less than all other indents.

Constructors

PPHsMode

Fields

data PPLayout Source #

Varieties of layout we can use.

Constructors

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 .

prettyPrimWithMode :: Pretty a => PPHsMode -> a -> Doc Source #

pretty-print with the default style and a given mode.