haskell-src-exts-1.19.0: Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer

Copyright(c) Niklas Broberg 2004-2009, (c) The GHC Team, Noel Winstanley 1997-2000
LicenseBSD-style (see the file LICENSE.txt)
MaintainerNiklas Broberg, d00nibro@chalmers.se
Stabilitystable
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Language.Haskell.Exts.Pretty

Contents

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

Pretty Tool Source # 

Methods

pretty :: Tool -> Doc

prettyPrec :: Int -> Tool -> Doc

Pretty SrcSpan Source # 

Methods

pretty :: SrcSpan -> Doc

prettyPrec :: Int -> SrcSpan -> Doc

Pretty SrcLoc Source # 

Methods

pretty :: SrcLoc -> Doc

prettyPrec :: Int -> SrcLoc -> Doc

Pretty (Alt l) Source # 

Methods

pretty :: Alt l -> Doc

prettyPrec :: Int -> Alt l -> Doc

Pretty (FieldUpdate l) Source # 

Methods

pretty :: FieldUpdate l -> Doc

prettyPrec :: Int -> FieldUpdate l -> Doc

Pretty (QualStmt l) Source # 

Methods

pretty :: QualStmt l -> Doc

prettyPrec :: Int -> QualStmt l -> Doc

Pretty (Stmt l) Source # 

Methods

pretty :: Stmt l -> Doc

prettyPrec :: Int -> Stmt l -> Doc

Pretty (PatField l) Source # 

Methods

pretty :: PatField l -> Doc

prettyPrec :: Int -> PatField l -> Doc

Pretty (RPat l) Source # 

Methods

pretty :: RPat l -> Doc

prettyPrec :: Int -> RPat l -> Doc

Pretty (RPatOp l) Source # 

Methods

pretty :: RPatOp l -> Doc

prettyPrec :: Int -> RPatOp l -> Doc

Pretty (PXAttr l) Source # 

Methods

pretty :: PXAttr l -> Doc

prettyPrec :: Int -> PXAttr l -> Doc

Pretty (Pat l) Source # 

Methods

pretty :: Pat l -> Doc

prettyPrec :: Int -> Pat l -> Doc

Pretty (RuleVar l) Source # 

Methods

pretty :: RuleVar l -> Doc

prettyPrec :: Int -> RuleVar l -> Doc

Pretty (Rule l) Source # 

Methods

pretty :: Rule l -> Doc

prettyPrec :: Int -> Rule l -> Doc

Pretty (Activation l) Source # 

Methods

pretty :: Activation l -> Doc

prettyPrec :: Int -> Activation l -> Doc

Pretty (Overlap l) Source # 

Methods

pretty :: Overlap l -> Doc

prettyPrec :: Int -> Overlap l -> Doc

Pretty (ModulePragma l) Source # 

Methods

pretty :: ModulePragma l -> Doc

prettyPrec :: Int -> ModulePragma l -> Doc

Pretty (CallConv l) Source # 

Methods

pretty :: CallConv l -> Doc

prettyPrec :: Int -> CallConv l -> Doc

Pretty (Safety l) Source # 

Methods

pretty :: Safety l -> Doc

prettyPrec :: Int -> Safety l -> Doc

Pretty (Splice l) Source # 

Methods

pretty :: Splice l -> Doc

prettyPrec :: Int -> Splice l -> Doc

Pretty (Bracket l) Source # 

Methods

pretty :: Bracket l -> Doc

prettyPrec :: Int -> Bracket l -> Doc

Pretty (XAttr l) Source # 

Methods

pretty :: XAttr l -> Doc

prettyPrec :: Int -> XAttr l -> Doc

Pretty (XName l) Source # 

Methods

pretty :: XName l -> Doc

prettyPrec :: Int -> XName l -> Doc

Pretty (Exp l) Source # 

Methods

pretty :: Exp l -> Doc

prettyPrec :: Int -> Exp l -> Doc

Pretty (Literal l) Source # 

Methods

pretty :: Literal l -> Doc

prettyPrec :: Int -> Literal l -> Doc

Pretty (Asst l) Source # 

Methods

pretty :: Asst l -> Doc

prettyPrec :: Int -> Asst l -> Doc

Pretty (Context l) Source # 

Methods

pretty :: Context l -> Doc

prettyPrec :: Int -> Context l -> Doc

Pretty (FunDep l) Source # 

Methods

pretty :: FunDep l -> Doc

prettyPrec :: Int -> FunDep l -> Doc

Pretty (Kind l) Source # 

Methods

pretty :: Kind l -> Doc

prettyPrec :: Int -> Kind l -> Doc

Pretty (TyVarBind l) Source # 

Methods

pretty :: TyVarBind l -> Doc

prettyPrec :: Int -> TyVarBind l -> Doc

Pretty (Promoted l) Source # 

Methods

pretty :: Promoted l -> Doc

prettyPrec :: Int -> Promoted l -> Doc

Pretty (Type l) Source # 

Methods

pretty :: Type l -> Doc

prettyPrec :: Int -> Type l -> Doc

Pretty (GuardedRhs l) Source # 

Methods

pretty :: GuardedRhs l -> Doc

prettyPrec :: Int -> GuardedRhs l -> Doc

Pretty (Rhs l) Source # 

Methods

pretty :: Rhs l -> Doc

prettyPrec :: Int -> Rhs l -> Doc

Pretty (Unpackedness l) Source # 

Methods

pretty :: Unpackedness l -> Doc

prettyPrec :: Int -> Unpackedness l -> Doc

Pretty (BangType l) Source # 

Methods

pretty :: BangType l -> Doc

prettyPrec :: Int -> BangType l -> Doc

Pretty (InstDecl l) Source # 

Methods

pretty :: InstDecl l -> Doc

prettyPrec :: Int -> InstDecl l -> Doc

Pretty (ClassDecl l) Source # 

Methods

pretty :: ClassDecl l -> Doc

prettyPrec :: Int -> ClassDecl l -> Doc

Pretty (GadtDecl l) Source # 

Methods

pretty :: GadtDecl l -> Doc

prettyPrec :: Int -> GadtDecl l -> Doc

Pretty (FieldDecl l) Source # 

Methods

pretty :: FieldDecl l -> Doc

prettyPrec :: Int -> FieldDecl l -> Doc

Pretty (ConDecl l) Source # 

Methods

pretty :: ConDecl l -> Doc

prettyPrec :: Int -> ConDecl l -> Doc

Pretty (QualConDecl l) Source # 

Methods

pretty :: QualConDecl l -> Doc

prettyPrec :: Int -> QualConDecl l -> Doc

Pretty (Match l) Source # 

Methods

pretty :: Match l -> Doc

prettyPrec :: Int -> Match l -> Doc

Pretty (IPBind l) Source # 

Methods

pretty :: IPBind l -> Doc

prettyPrec :: Int -> IPBind l -> Doc

Pretty (Deriving l) Source # 

Methods

pretty :: Deriving l -> Doc

prettyPrec :: Int -> Deriving l -> Doc

Pretty (InstHead l) Source # 

Methods

pretty :: InstHead l -> Doc

prettyPrec :: Int -> InstHead l -> Doc

Pretty (InstRule l) Source # 

Methods

pretty :: InstRule l -> Doc

prettyPrec :: Int -> InstRule l -> Doc

Pretty (DeclHead l) Source # 

Methods

pretty :: DeclHead l -> Doc

prettyPrec :: Int -> DeclHead l -> Doc

Pretty (ResultSig l) Source # 

Methods

pretty :: ResultSig l -> Doc

prettyPrec :: Int -> ResultSig l -> Doc

Pretty (InjectivityInfo l) Source # 

Methods

pretty :: InjectivityInfo l -> Doc

prettyPrec :: Int -> InjectivityInfo l -> Doc

Pretty (DataOrNew l) Source # 

Methods

pretty :: DataOrNew l -> Doc

prettyPrec :: Int -> DataOrNew l -> Doc

Pretty (Role l) Source # 

Methods

pretty :: Role l -> Doc

prettyPrec :: Int -> Role l -> Doc

Pretty (BooleanFormula l) Source # 

Methods

pretty :: BooleanFormula l -> Doc

prettyPrec :: Int -> BooleanFormula l -> Doc

Pretty (Annotation l) Source # 

Methods

pretty :: Annotation l -> Doc

prettyPrec :: Int -> Annotation l -> Doc

Pretty (TypeEqn l) Source # 

Methods

pretty :: TypeEqn l -> Doc

prettyPrec :: Int -> TypeEqn l -> Doc

Pretty (Decl l) Source # 

Methods

pretty :: Decl l -> Doc

prettyPrec :: Int -> Decl l -> Doc

Pretty (Assoc l) Source # 

Methods

pretty :: Assoc l -> Doc

prettyPrec :: Int -> Assoc l -> Doc

Pretty (ImportSpec l) Source # 

Methods

pretty :: ImportSpec l -> Doc

prettyPrec :: Int -> ImportSpec l -> Doc

Pretty (ImportSpecList l) Source # 

Methods

pretty :: ImportSpecList l -> Doc

prettyPrec :: Int -> ImportSpecList l -> Doc

Pretty (ImportDecl l) Source # 

Methods

pretty :: ImportDecl l -> Doc

prettyPrec :: Int -> ImportDecl l -> Doc

Pretty (Namespace l) Source # 

Methods

pretty :: Namespace l -> Doc

prettyPrec :: Int -> Namespace l -> Doc

Pretty (ExportSpec l) Source # 

Methods

pretty :: ExportSpec l -> Doc

prettyPrec :: Int -> ExportSpec l -> Doc

Pretty (ExportSpecList l) Source # 

Methods

pretty :: ExportSpecList l -> Doc

prettyPrec :: Int -> ExportSpecList l -> Doc

Pretty (ModuleHead l) Source # 

Methods

pretty :: ModuleHead l -> Doc

prettyPrec :: Int -> ModuleHead l -> Doc

Pretty (Module pos) Source # 

Methods

pretty :: Module pos -> Doc

prettyPrec :: Int -> Module pos -> Doc

Pretty (CName l) Source # 

Methods

pretty :: CName l -> Doc

prettyPrec :: Int -> CName l -> Doc

Pretty (Op l) Source # 

Methods

pretty :: Op l -> Doc

prettyPrec :: Int -> Op l -> Doc

Pretty (QOp l) Source # 

Methods

pretty :: QOp l -> Doc

prettyPrec :: Int -> QOp l -> Doc

Pretty (IPName l) Source # 

Methods

pretty :: IPName l -> Doc

prettyPrec :: Int -> IPName l -> Doc

Pretty (Name l) Source # 

Methods

pretty :: Name l -> Doc

prettyPrec :: Int -> Name l -> Doc

Pretty (QName l) Source # 

Methods

pretty :: QName l -> Doc

prettyPrec :: Int -> QName l -> Doc

Pretty (SpecialCon l) Source # 

Methods

pretty :: SpecialCon l -> Doc

prettyPrec :: Int -> SpecialCon l -> Doc

Pretty (ModuleName l) Source # 

Methods

pretty :: ModuleName l -> Doc

prettyPrec :: Int -> ModuleName l -> Doc

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 :: * #

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.

Instances

Eq Style 

Methods

(==) :: Style -> Style -> Bool #

(/=) :: Style -> Style -> Bool #

Show Style 

Methods

showsPrec :: Int -> Style -> ShowS #

show :: Style -> String #

showList :: [Style] -> ShowS #

Generic Style 

Associated Types

type Rep Style :: * -> * #

Methods

from :: Style -> Rep Style x #

to :: Rep Style x -> Style #

type Rep Style 

style :: Style #

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

data Mode :: * #

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.

Instances

Eq Mode 

Methods

(==) :: Mode -> Mode -> Bool #

(/=) :: Mode -> Mode -> Bool #

Show Mode 

Methods

showsPrec :: Int -> Mode -> ShowS #

show :: Mode -> String #

showList :: [Mode] -> ShowS #

Generic Mode 

Associated Types

type Rep Mode :: * -> * #

Methods

from :: Mode -> Rep Mode x #

to :: Rep Mode x -> Mode #

type Rep Mode 
type Rep Mode = D1 (MetaData "Mode" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.3" 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

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

Instances

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.