haskell-src-1.0.2.0: Support for manipulating Haskell source code

Copyright(c) The GHC Team Noel Winstanley 1997-2000
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Language.Haskell.Pretty

Contents

Description

Pretty printer for Haskell.

Synopsis

Pretty printing

class Pretty a #

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

Instances

Pretty HsGuardedAlt # 

Methods

pretty :: HsGuardedAlt -> Doc

prettyPrec :: Int -> HsGuardedAlt -> Doc

Pretty HsGuardedAlts # 

Methods

pretty :: HsGuardedAlts -> Doc

prettyPrec :: Int -> HsGuardedAlts -> Doc

Pretty HsAlt # 

Methods

pretty :: HsAlt -> Doc

prettyPrec :: Int -> HsAlt -> Doc

Pretty HsFieldUpdate # 

Methods

pretty :: HsFieldUpdate -> Doc

prettyPrec :: Int -> HsFieldUpdate -> Doc

Pretty HsStmt # 

Methods

pretty :: HsStmt -> Doc

prettyPrec :: Int -> HsStmt -> Doc

Pretty HsPatField # 

Methods

pretty :: HsPatField -> Doc

prettyPrec :: Int -> HsPatField -> Doc

Pretty HsPat # 

Methods

pretty :: HsPat -> Doc

prettyPrec :: Int -> HsPat -> Doc

Pretty HsExp # 

Methods

pretty :: HsExp -> Doc

prettyPrec :: Int -> HsExp -> Doc

Pretty HsLiteral # 

Methods

pretty :: HsLiteral -> Doc

prettyPrec :: Int -> HsLiteral -> Doc

Pretty HsType # 

Methods

pretty :: HsType -> Doc

prettyPrec :: Int -> HsType -> Doc

Pretty HsQualType # 

Methods

pretty :: HsQualType -> Doc

prettyPrec :: Int -> HsQualType -> Doc

Pretty HsSafety # 

Methods

pretty :: HsSafety -> Doc

prettyPrec :: Int -> HsSafety -> Doc

Pretty HsGuardedRhs # 

Methods

pretty :: HsGuardedRhs -> Doc

prettyPrec :: Int -> HsGuardedRhs -> Doc

Pretty HsRhs # 

Methods

pretty :: HsRhs -> Doc

prettyPrec :: Int -> HsRhs -> Doc

Pretty HsBangType # 

Methods

pretty :: HsBangType -> Doc

prettyPrec :: Int -> HsBangType -> Doc

Pretty HsConDecl # 

Methods

pretty :: HsConDecl -> Doc

prettyPrec :: Int -> HsConDecl -> Doc

Pretty HsMatch # 

Methods

pretty :: HsMatch -> Doc

prettyPrec :: Int -> HsMatch -> Doc

Pretty HsDecl # 

Methods

pretty :: HsDecl -> Doc

prettyPrec :: Int -> HsDecl -> Doc

Pretty HsAssoc # 

Methods

pretty :: HsAssoc -> Doc

prettyPrec :: Int -> HsAssoc -> Doc

Pretty HsImportSpec # 

Methods

pretty :: HsImportSpec -> Doc

prettyPrec :: Int -> HsImportSpec -> Doc

Pretty HsImportDecl # 

Methods

pretty :: HsImportDecl -> Doc

prettyPrec :: Int -> HsImportDecl -> Doc

Pretty HsExportSpec # 

Methods

pretty :: HsExportSpec -> Doc

prettyPrec :: Int -> HsExportSpec -> Doc

Pretty HsModule # 

Methods

pretty :: HsModule -> Doc

prettyPrec :: Int -> HsModule -> Doc

Pretty HsCName # 

Methods

pretty :: HsCName -> Doc

prettyPrec :: Int -> HsCName -> Doc

Pretty HsOp # 

Methods

pretty :: HsOp -> Doc

prettyPrec :: Int -> HsOp -> Doc

Pretty HsQOp # 

Methods

pretty :: HsQOp -> Doc

prettyPrec :: Int -> HsQOp -> Doc

Pretty HsName # 

Methods

pretty :: HsName -> Doc

prettyPrec :: Int -> HsName -> Doc

Pretty HsQName # 

Methods

pretty :: HsQName -> Doc

prettyPrec :: Int -> HsQName -> Doc

Pretty Module # 

Methods

pretty :: Module -> Doc

prettyPrec :: Int -> Module -> Doc

prettyPrintStyleMode :: Pretty a => Style -> PPHsMode -> a -> String #

pretty-print with a given style and mode.

prettyPrintWithMode :: Pretty a => PPHsMode -> a -> String #

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

prettyPrint :: Pretty a => a -> String #

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 #

Pretty-printing parameters.

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

Constructors

PPHsMode 

Fields

type Indent = Int #

data PPLayout #

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 #

The default mode: pretty-print using the offside rule and sensible defaults.