Floskell.Printers

floskell-0.11.1: A flexible Haskell source code pretty printer

Safe Haskell | None
Language | Haskell2010

Floskell.Printers

Contents

- Basic printing
- Tab stops
- Combinators
- Indentation
- Wrapping
- Operators

Synopsis

- getConfig :: (Config -> b) -> Printer b
- getOption :: (OptionConfig -> a) -> Printer a
- cut :: Printer a -> Printer a
- closeEolComment :: Printer ()
- oneline :: Printer a -> Printer a
- ignoreOneline :: Printer a -> Printer a
- write :: Text -> Printer ()
- string :: String -> Printer ()
- int :: Int -> Printer ()
- space :: Printer ()
- newline :: Printer ()
- ensureNewline :: Printer ()
- blankline :: Printer ()
- spaceOrNewline :: Printer ()
- withTabStops :: [(TabStop, Maybe Int)] -> Printer a -> Printer a
- atTabStop :: TabStop -> Printer ()
- mayM_ :: Maybe a -> (a -> Printer ()) -> Printer ()
- withPrefix :: Applicative f => f a -> (x -> f b) -> x -> f b
- withPostfix :: Applicative f => f a -> (x -> f b) -> x -> f b
- withIndentConfig :: (IndentConfig -> Indent) -> Printer a -> (Int -> Printer a) -> Printer a
- withIndent :: (IndentConfig -> Indent) -> Printer a -> Printer a
- withIndentFlex :: (IndentConfig -> Indent) -> Printer a -> Printer a
- withIndentAfter :: (IndentConfig -> Indent) -> Printer () -> Printer a -> Printer a
- withIndentBy :: (IndentConfig -> Int) -> Printer a -> Printer a
- withLayout :: (LayoutConfig -> Layout) -> Printer a -> Printer a -> Printer a
- inter :: Printer () -> [Printer ()] -> Printer ()
- getNextColumn :: Printer Int
- column :: Int -> Printer a -> Printer a
- aligned :: Printer a -> Printer a
- indented :: Int -> Printer a -> Printer a
- onside :: Printer a -> Printer a
- suppressOnside :: Printer () -> Printer ()
- depend :: Text -> Printer a -> Printer a
- depend' :: Printer () -> Printer a -> Printer a
- parens :: Printer () -> Printer ()
- brackets :: Printer () -> Printer ()
- group :: LayoutContext -> Text -> Text -> Printer () -> Printer ()
- groupH :: LayoutContext -> Text -> Text -> Printer () -> Printer ()
- groupV :: LayoutContext -> Text -> Text -> Printer () -> Printer ()
- operator :: LayoutContext -> Text -> Printer ()
- operatorH :: LayoutContext -> Text -> Printer ()
- operatorV :: LayoutContext -> Text -> Printer ()
- alignOnOperator :: LayoutContext -> Text -> Printer a -> Printer a
- withOperatorFormatting :: LayoutContext -> Text -> Printer () -> (Printer () -> Printer a) -> Printer a
- withOperatorFormattingH :: LayoutContext -> Text -> Printer () -> (Printer () -> Printer a) -> Printer a
- withOperatorFormattingV :: LayoutContext -> Text -> Printer () -> (Printer () -> Printer a) -> Printer a
- operatorSectionL :: LayoutContext -> Text -> Printer () -> Printer ()
- operatorSectionR :: LayoutContext -> Text -> Printer () -> Printer ()
- comma :: Printer ()

# Documentation

getConfig :: (Config -> b) -> Printer b #

Query part of the pretty printer config

getOption :: (OptionConfig -> a) -> Printer a #

Query pretty printer options

cut :: Printer a -> Printer a #

Try only the first (i.e. locally best) solution to the given pretty printer. Use this function to improve performance whenever the formatting of an AST node has no effect on the penalty of any following AST node, such as top-level declarations or case branches.

closeEolComment :: Printer () #

oneline :: Printer a -> Printer a #

ignoreOneline :: Printer a -> Printer a #

# Basic printing

write :: Text -> Printer () #

Write out a string, updating the current position information.

string :: String -> Printer () #

Write a string.

int :: Int -> Printer () #

Write an integral.

space :: Printer () #

Write a space.

newline :: Printer () #

Output a newline.

ensureNewline :: Printer () #

Output a newline if not at the start of a line

blankline :: Printer () #

spaceOrNewline :: Printer () #

# Tab stops

withTabStops :: [(TabStop, Maybe Int)] -> Printer a -> Printer a #

atTabStop :: TabStop -> Printer () #

# Combinators

mayM_ :: Maybe a -> (a -> Printer ()) -> Printer () #

withPrefix :: Applicative f => f a -> (x -> f b) -> x -> f b #

withPostfix :: Applicative f => f a -> (x -> f b) -> x -> f b #

withIndentConfig :: (IndentConfig -> Indent) -> Printer a -> (Int -> Printer a) -> Printer a #

withIndent :: (IndentConfig -> Indent) -> Printer a -> Printer a #

withIndentFlex :: (IndentConfig -> Indent) -> Printer a -> Printer a #

withIndentAfter :: (IndentConfig -> Indent) -> Printer () -> Printer a -> Printer a #

withIndentBy :: (IndentConfig -> Int) -> Printer a -> Printer a #

withLayout :: (LayoutConfig -> Layout) -> Printer a -> Printer a -> Printer a #

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

# Indentation

getNextColumn :: Printer Int #

Get the column for the next printed character.

column :: Int -> Printer a -> Printer a #

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

aligned :: Printer a -> Printer a #

indented :: Int -> Printer a -> Printer a #

Increase indentation level by n spaces for the given printer.

onside :: Printer a -> Printer a #

Increase indentation level by n spaces for the given printer, but ignore increase when computing further indentations.

suppressOnside :: Printer () -> Printer () #

Temporarily ignore any onside identation.

depend :: Text -> Printer a -> Printer a #

depend' :: Printer () -> Printer a -> Printer a #

parens :: Printer () -> Printer () #

Wrap in parens.

brackets :: Printer () -> Printer () #

Wrap in brackets.

# Wrapping

group :: LayoutContext -> Text -> Text -> Printer () -> Printer () #

groupH :: LayoutContext -> Text -> Text -> Printer () -> Printer () #

groupV :: LayoutContext -> Text -> Text -> Printer () -> Printer () #

# Operators

operator :: LayoutContext -> Text -> Printer () #

operatorH :: LayoutContext -> Text -> Printer () #

operatorV :: LayoutContext -> Text -> Printer () #

alignOnOperator :: LayoutContext -> Text -> Printer a -> Printer a #

withOperatorFormatting :: LayoutContext -> Text -> Printer () -> (Printer () -> Printer a) -> Printer a #

withOperatorFormattingH :: LayoutContext -> Text -> Printer () -> (Printer () -> Printer a) -> Printer a #

withOperatorFormattingV :: LayoutContext -> Text -> Printer () -> (Printer () -> Printer a) -> Printer a #

operatorSectionL :: LayoutContext -> Text -> Printer () -> Printer () #

operatorSectionR :: LayoutContext -> Text -> Printer () -> Printer () #

comma :: Printer () #