| Copyright | (c) 2009 Bernie Pope |
|---|---|
| License | BSD-style |
| Maintainer | bjpop@csse.unimelb.edu.au |
| Stability | experimental |
| Portability | ghc |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Language.Python.Common.Pretty
Description
Convenience class for pretty printing combinators.
Synopsis
- text :: String -> Doc
- (<>) :: Doc -> Doc -> Doc
- empty :: Doc
- data Doc
- render :: Doc -> String
- (<+>) :: Doc -> Doc -> Doc
- parens :: Doc -> Doc
- hsep :: [Doc] -> Doc
- punctuate :: Doc -> [Doc] -> [Doc]
- comma :: Doc
- space :: Doc
- equals :: Doc
- int :: Int -> Doc
- integer :: Integer -> Doc
- double :: Double -> Doc
- data TextDetails
- data Mode
- data Style = Style {
- mode :: Mode
- lineLength :: Int
- ribbonsPerLine :: Float
- style :: Style
- ($$) :: Doc -> Doc -> Doc
- ($+$) :: Doc -> Doc -> Doc
- braces :: Doc -> Doc
- brackets :: Doc -> Doc
- cat :: [Doc] -> Doc
- char :: Char -> Doc
- colon :: Doc
- doubleQuotes :: Doc -> 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
- lbrace :: Doc
- lbrack :: Doc
- lparen :: Doc
- nest :: Int -> Doc -> Doc
- ptext :: String -> Doc
- quotes :: Doc -> Doc
- rational :: Rational -> Doc
- rbrace :: Doc
- rbrack :: Doc
- renderStyle :: Style -> Doc -> String
- rparen :: Doc
- semi :: Doc
- sep :: [Doc] -> Doc
- sizedText :: Int -> String -> Doc
- vcat :: [Doc] -> Doc
- zeroWidthText :: String -> Doc
- class Pretty a where
- prettyText :: Pretty a => a -> String
- prettyPrefix :: Pretty a => Int -> a -> Doc
- parensIf :: Pretty a => (a -> Bool) -> a -> Doc
- perhaps :: Pretty a => Maybe a -> Doc -> Doc
- commaList :: Pretty a => [a] -> Doc
- equalsList :: Pretty a => [a] -> Doc
Documentation
Instances
| NFData Doc | |||||
Defined in Text.PrettyPrint.HughesPJ | |||||
| Monoid Doc | |||||
| Semigroup Doc | |||||
| IsString Doc | |||||
Defined in Text.PrettyPrint.HughesPJ Methods fromString :: String -> Doc | |||||
| Generic Doc | |||||
Defined in Text.PrettyPrint.HughesPJ Associated Types
| |||||
| Show Doc | |||||
| Eq Doc | |||||
| type Rep Doc | |||||
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 ())))) | |||||
data TextDetails #
Instances
| NFData TextDetails | |||||
Defined in Text.PrettyPrint.Annotated.HughesPJ Methods rnf :: TextDetails -> () | |||||
| Generic TextDetails | |||||
Defined in Text.PrettyPrint.Annotated.HughesPJ Associated Types
| |||||
| Show TextDetails | |||||
Defined in Text.PrettyPrint.Annotated.HughesPJ Methods showsPrec :: Int -> TextDetails -> ShowS show :: TextDetails -> String showList :: [TextDetails] -> ShowS | |||||
| Eq TextDetails | |||||
Defined in Text.PrettyPrint.Annotated.HughesPJ | |||||
| type Rep TextDetails | |||||
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)))) | |||||
Constructors
| PageMode | |
| ZigZagMode | |
| LeftMode | |
| OneLineMode |
Instances
| Generic Mode | |||||
Defined in Text.PrettyPrint.Annotated.HughesPJ Associated Types
| |||||
| Show Mode | |||||
| Eq 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-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))) | |||||
Constructors
| Style | |
Fields
| |
Instances
| Generic Style | |||||
Defined in Text.PrettyPrint.Annotated.HughesPJ Associated Types
| |||||
| Show Style | |||||
| Eq 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-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)))) | |||||
doubleQuotes :: Doc -> Doc #
fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a #
renderStyle :: Style -> Doc -> String #
zeroWidthText :: String -> Doc #
All types which can be transformed into a Doc.
Instances
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.
equalsList :: Pretty a => [a] -> Doc Source #
A list of things separated by equals signs.