purescript-0.8.2.0: PureScript Programming Language Compiler

Safe HaskellNone
LanguageHaskell98

Language.PureScript.Pretty.Common

Description

Common pretty-printing utility functions

Synopsis

Documentation

parens :: String -> String Source

Wrap a string in parentheses

parensPos :: Emit gen => gen -> gen Source

intercalate :: Monoid m => m -> [m] -> m Source

Generalize intercalate slightly for monoids

class Monoid gen => Emit gen where Source

Methods

emit :: String -> gen Source

addMapping :: SourceSpan -> gen Source

newtype StrPos Source

String with length and source-map entries

Constructors

StrPos (SourcePos, String, [SMap]) 

Instances

Monoid StrPos Source

Make a monoid where append consists of concatenating the string part, adding the lengths appropriately and advancing source mappings on the right hand side to account for the length of the left.

Emit StrPos Source 

data PrinterState Source

Constructors

PrinterState 

Fields

indent :: Int
 

blockIndent :: Int Source

Number of characters per identation level

withIndent :: Emit gen => StateT PrinterState Maybe gen -> StateT PrinterState Maybe gen Source

Pretty print with a new indentation level

currentIndent :: Emit gen => StateT PrinterState Maybe gen Source

Get the current indentation level

prettyPrintMany :: Emit gen => (a -> StateT PrinterState Maybe gen) -> [a] -> StateT PrinterState Maybe gen Source

Print many lines

prettyPrintObjectKey :: String -> String Source

Prints an object key, escaping reserved names.

before :: Box -> Box -> Box Source

Place a box before another, vertically when the first box takes up multiple lines.