hindent-1.0: Extensible Haskell pretty printer

Safe HaskellNone

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 :: Comment -> 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 :: Char -> [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 aSource

Wrap in parens.

brackets :: Printer a -> Printer aSource

Wrap in brackets.

braces :: Printer a -> Printer aSource

Wrap in braces.

Indentation

indented :: Int64 -> Printer a -> Printer aSource

Increase indentation level by n spaces for the given printer.

column :: Int64 -> Printer a -> Printer aSource

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

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

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

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

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

getIndentSpaces :: Printer Int64Source

Indent spaces, e.g. 2.

getColumnLimit :: Printer Int64Source

Column limit, e.g. 80

Predicates

Sandboxing

sandbox :: MonadState s m => m a -> m sSource

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

Fallback

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

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