language-python-0.5.4: Parsing and pretty printing of Python code.

Copyright | (c) 2009 Bernie Pope
License | BSD-style
Maintainer | bjpop@csse.unimelb.edu.au
Stability | experimental
Portability | ghc
Safe Haskell | Safe
Language | Haskell98

Language.Python.Common.Pretty

Description

Convenience class for pretty printing combinators.

Synopsis

- 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

# Documentation

class Pretty a where #

All types which can be transformed into a `Doc`.

Minimal complete definition

pretty

Methods

pretty :: a -> Doc #

Instances

Pretty Bool # |
Methods pretty :: Bool -> Doc #
Pretty Double # |
Methods pretty :: Double -> Doc #
Pretty Int # |
Methods pretty :: Int -> Doc #
Pretty Integer # |
Methods pretty :: Integer -> Doc #
Pretty String # |
Methods pretty :: String -> Doc #
Pretty SrcSpan # |
Methods pretty :: SrcSpan -> Doc #
Pretty SrcLocation # |
Methods pretty :: SrcLocation -> Doc #
Pretty a => Pretty (Maybe a) # |
Methods pretty :: Maybe a -> Doc #

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

Transform values into strings.

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

Print just the prefix of something

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

Conditionally wrap parentheses around an item.

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

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

A list of things separated by commas.