language-python-0.5.8: Parsing and pretty printing of Python code.
Copyright(c) 2009 Bernie Pope
LicenseBSD-style
Maintainerbjpop@csse.unimelb.edu.au
Stabilityexperimental
Portabilityghc
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Python.Common.Pretty

Description

Convenience class for pretty printing combinators.

Synopsis

Documentation

text :: String -> Doc #

(<>) :: Doc -> Doc -> Doc #

data Doc #

Instances

Instances details
NFData Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

rnf :: Doc -> ()

Monoid Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

mempty :: Doc

mappend :: Doc -> Doc -> Doc

mconcat :: [Doc] -> Doc

Semigroup Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

(<>) :: Doc -> Doc -> Doc

sconcat :: NonEmpty Doc -> Doc

stimes :: Integral b => b -> Doc -> Doc

IsString Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

fromString :: String -> Doc

Generic Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Associated Types

type Rep Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

type Rep Doc = D1 ('MetaData "Doc" "Text.PrettyPrint.HughesPJ" "pretty-1.1.3.6-inplace" 'True) (C1 ('MetaCons "Doc" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ()))))

Methods

from :: Doc -> Rep Doc x

to :: Rep Doc x -> Doc

Show Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

showsPrec :: Int -> Doc -> ShowS

show :: Doc -> String

showList :: [Doc] -> ShowS

Eq Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

(==) :: Doc -> Doc -> Bool

(/=) :: Doc -> Doc -> Bool

type Rep Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

type Rep Doc = D1 ('MetaData "Doc" "Text.PrettyPrint.HughesPJ" "pretty-1.1.3.6-inplace" 'True) (C1 ('MetaCons "Doc" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ()))))

render :: Doc -> String #

(<+>) :: Doc -> Doc -> Doc #

parens :: Doc -> Doc #

hsep :: [Doc] -> Doc #

punctuate :: Doc -> [Doc] -> [Doc] #

int :: Int -> Doc #

integer :: Integer -> Doc #

double :: Double -> Doc #

data TextDetails #

Constructors

Chr !Char 
Str String 
PStr String 

Instances

Instances details
NFData TextDetails 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Methods

rnf :: TextDetails -> ()

Generic TextDetails 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Associated Types

type Rep TextDetails 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

type Rep TextDetails = D1 ('MetaData "TextDetails" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6-inplace" 'False) (C1 ('MetaCons "Chr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Char)) :+: (C1 ('MetaCons "Str" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "PStr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))

Methods

from :: TextDetails -> Rep TextDetails x

to :: Rep TextDetails x -> TextDetails

Show TextDetails 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Methods

showsPrec :: Int -> TextDetails -> ShowS

show :: TextDetails -> String

showList :: [TextDetails] -> ShowS

Eq TextDetails 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Methods

(==) :: TextDetails -> TextDetails -> Bool

(/=) :: TextDetails -> TextDetails -> Bool

type Rep TextDetails 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

type Rep TextDetails = D1 ('MetaData "TextDetails" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6-inplace" 'False) (C1 ('MetaCons "Chr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Char)) :+: (C1 ('MetaCons "Str" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "PStr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))

data Mode #

Instances

Instances details
Generic Mode 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Associated Types

type Rep Mode 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

type Rep Mode = D1 ('MetaData "Mode" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6-inplace" 'False) ((C1 ('MetaCons "PageMode" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ZigZagMode" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LeftMode" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OneLineMode" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Mode -> Rep Mode x

to :: Rep Mode x -> Mode

Show Mode 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Methods

showsPrec :: Int -> Mode -> ShowS

show :: Mode -> String

showList :: [Mode] -> ShowS

Eq Mode 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Methods

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

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

type Rep Mode 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

type Rep Mode = D1 ('MetaData "Mode" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6-inplace" 'False) ((C1 ('MetaCons "PageMode" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ZigZagMode" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LeftMode" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OneLineMode" 'PrefixI 'False) (U1 :: Type -> Type)))

data Style #

Constructors

Style 

Fields

Instances

Instances details
Generic Style 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Associated Types

type Rep Style 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

type Rep Style = D1 ('MetaData "Style" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6-inplace" '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))))

Methods

from :: Style -> Rep Style x

to :: Rep Style x -> Style

Show Style 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Methods

showsPrec :: Int -> Style -> ShowS

show :: Style -> String

showList :: [Style] -> ShowS

Eq Style 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

Methods

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

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

type Rep Style 
Instance details

Defined in Text.PrettyPrint.Annotated.HughesPJ

type Rep Style = D1 ('MetaData "Style" "Text.PrettyPrint.Annotated.HughesPJ" "pretty-1.1.3.6-inplace" '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))))

($$) :: Doc -> Doc -> Doc #

($+$) :: Doc -> Doc -> Doc #

braces :: Doc -> Doc #

cat :: [Doc] -> Doc #

char :: Char -> Doc #

fcat :: [Doc] -> Doc #

float :: Float -> Doc #

fsep :: [Doc] -> Doc #

fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a #

hang :: Doc -> Int -> Doc -> Doc #

hcat :: [Doc] -> Doc #

isEmpty :: Doc -> Bool #

nest :: Int -> Doc -> Doc #

ptext :: String -> Doc #

quotes :: Doc -> Doc #

rational :: Rational -> Doc #

renderStyle :: Style -> Doc -> String #

sep :: [Doc] -> Doc #

sizedText :: Int -> String -> Doc #

vcat :: [Doc] -> Doc #

zeroWidthText :: String -> Doc #

class Pretty a where Source #

All types which can be transformed into a Doc.

Methods

pretty :: a -> Doc Source #

Instances

Instances details
Pretty ParseError Source # 
Instance details

Defined in Language.Python.Common.PrettyParseError

Pretty SrcLocation Source # 
Instance details

Defined in Language.Python.Common.SrcLocation

Pretty SrcSpan Source # 
Instance details

Defined in Language.Python.Common.SrcLocation

Methods

pretty :: SrcSpan -> Doc Source #

Pretty Token Source # 
Instance details

Defined in Language.Python.Common.PrettyToken

Methods

pretty :: Token -> Doc Source #

Pretty Integer Source # 
Instance details

Defined in Language.Python.Common.Pretty

Methods

pretty :: Integer -> Doc Source #

Pretty String Source # 
Instance details

Defined in Language.Python.Common.Pretty

Methods

pretty :: String -> Doc Source #

Pretty Bool Source # 
Instance details

Defined in Language.Python.Common.Pretty

Methods

pretty :: Bool -> Doc Source #

Pretty Double Source # 
Instance details

Defined in Language.Python.Common.Pretty

Methods

pretty :: Double -> Doc Source #

Pretty Int Source # 
Instance details

Defined in Language.Python.Common.Pretty

Methods

pretty :: Int -> Doc Source #

Pretty (Argument a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Argument a -> Doc Source #

Pretty (AssignOp a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: AssignOp a -> Doc Source #

Pretty (CompFor a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: CompFor a -> Doc Source #

Pretty (CompIf a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: CompIf a -> Doc Source #

Pretty (CompIter a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: CompIter a -> Doc Source #

Pretty (Comprehension a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Pretty (ComprehensionExpr a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Pretty (Decorator a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Decorator a -> Doc Source #

Pretty (DictKeyDatumList a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Pretty (ExceptClause a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: ExceptClause a -> Doc Source #

Pretty (Expr a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Expr a -> Doc Source #

Pretty (FromItem a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: FromItem a -> Doc Source #

Pretty (FromItems a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: FromItems a -> Doc Source #

Pretty (Handler a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Handler a -> Doc Source #

Pretty (Ident a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Ident a -> Doc Source #

Pretty (ImportItem a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: ImportItem a -> Doc Source #

Pretty (ImportRelative a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Pretty (Module a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Module a -> Doc Source #

Pretty (Op a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Op a -> Doc Source #

Pretty (ParamTuple a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: ParamTuple a -> Doc Source #

Pretty (Parameter a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Parameter a -> Doc Source #

Pretty (RaiseExpr a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: RaiseExpr a -> Doc Source #

Pretty (Slice a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Slice a -> Doc Source #

Pretty (Statement a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: Statement a -> Doc Source #

Pretty (YieldArg a) Source # 
Instance details

Defined in Language.Python.Common.PrettyAST

Methods

pretty :: YieldArg a -> Doc Source #

Pretty a => Pretty (Maybe a) Source # 
Instance details

Defined in Language.Python.Common.Pretty

Methods

pretty :: Maybe a -> Doc Source #

prettyText :: Pretty a => a -> String Source #

Transform values into strings.

prettyPrefix :: Pretty a => Int -> a -> Doc Source #

Print just the prefix of something

parensIf :: Pretty a => (a -> Bool) -> a -> Doc Source #

Conditionally wrap parentheses around an item.

perhaps :: Pretty a => Maybe a -> Doc -> Doc Source #

commaList :: Pretty a => [a] -> Doc Source #

A list of things separated by commas.

equalsList :: Pretty a => [a] -> Doc Source #

A list of things separated by equals signs.