hindent-3.2: Extensible Haskell pretty printer

Safe HaskellNone
LanguageHaskell98

HIndent.Pretty

Contents

Description

Pretty printing.

Synopsis

Printing

pretty :: Pretty ast => ast NodeInfo -> Printer () Source

Pretty print using extenders.

prettyNoExt :: Pretty ast => ast NodeInfo -> Printer () Source

Run the basic printer for the given node without calling an extension hook for this node, but do allow extender hooks in child nodes. Also auto-inserts comments.

Insertion

write :: Builder -> Printer () Source

Write out a string, updating the current position information.

newline :: Printer () Source

Output a newline.

space :: Printer () Source

Write a space.

comma :: Printer () Source

Write a comma.

int :: Integral n => n -> Printer () Source

Write an integral.

string :: String -> Printer () Source

Write a string.

Common node types

maybeCtx :: Maybe (Context NodeInfo) -> Printer () Source

Maybe render a class context.

printComment :: ComInfo -> Printer () Source

Pretty print a comment.

Interspersing

inter :: Printer () -> [Printer ()] -> Printer () Source

Print all the printers separated by sep.

spaced :: [Printer ()] -> Printer () Source

Print all the printers separated by spaces.

lined :: [Printer ()] -> Printer () Source

Print all the printers separated by spaces.

prefixedLined :: Text -> [Printer ()] -> Printer () Source

Print all the printers separated newlines and optionally a line prefix.

commas :: [Printer ()] -> Printer () Source

Print all the printers separated by commas.

Wrapping

parens :: Printer a -> Printer a Source

Wrap in parens.

brackets :: Printer a -> Printer a Source

Wrap in brackets.

braces :: Printer a -> Printer a Source

Wrap in braces.

Indentation

indented :: Int64 -> Printer a -> Printer a Source

Increase indentation level by n spaces for the given printer.

column :: Int64 -> Printer a -> Printer a Source

Set the (newline-) indent level to the given column for the given printer.

depend :: Printer () -> Printer b -> Printer b Source

Make the latter's indentation depend upon the end column of the former.

dependBind :: Printer a -> (a -> Printer b) -> Printer b Source

Make the latter's indentation depend upon the end column of the former.

swing :: Printer () -> Printer b -> Printer b Source

Swing the second printer below and indented with respect to the first.

getIndentSpaces :: Printer Int64 Source

Indent spaces, e.g. 2.

getColumnLimit :: Printer Int64 Source

Column limit, e.g. 80

Predicates

Sandboxing

sandbox :: MonadState s m => m a -> m (a, s) Source

Play with a printer and then restore the state to what it was before.

Fallback

pretty' :: (Pretty ast, Pretty (ast SrcSpanInfo), Functor ast) => ast NodeInfo -> Printer () Source

Pretty print using HSE's own printer. The Pretty class here is HSE's.