purescript-0.15.12: PureScript Programming Language Compiler

Safe Haskell | Safe-Inferred
Language | Haskell2010

Language.PureScript.Pretty.Common

Description

Common pretty-printing utility functions

Synopsis

- parensT :: Text -> Text
- parensPos :: Emit gen => gen -> gen
- intercalate :: Monoid m => m -> [m] -> m
- class Monoid gen => Emit gen where
  - emit :: Text -> gen
  - addMapping :: SourceSpan -> gen
- data SMap = SMap Text SourcePos SourcePos
- newtype StrPos = StrPos (SourcePos, Text, [SMap])
- newtype PlainString = PlainString Text
- runPlainString :: PlainString -> Text
- addMapping' :: Emit gen => Maybe SourceSpan -> gen
- bumpPos :: SourcePos -> SMap -> SMap
- addPos :: SourcePos -> SourcePos -> SourcePos
- data PrinterState = PrinterState {
  - indent :: Int
  }
- blockIndent :: Int
- withIndent :: StateT PrinterState Maybe gen -> StateT PrinterState Maybe gen
- currentIndent :: Emit gen => StateT PrinterState Maybe gen
- objectKeyRequiresQuoting :: Text -> Bool
- before :: Box -> Box -> Box
- beforeWithSpace :: Box -> Box -> Box
- endWith :: Box -> Box -> Box

# Documentation

parensT :: Text -> Text #

parensPos :: Emit gen => gen -> gen #

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

Generalize intercalate slightly for monoids

class Monoid gen => Emit gen where #

Methods

emit :: Text -> gen #

addMapping :: SourceSpan -> gen #

#### Instances

Instances details

Emit PlainString # |
Instance details Defined in Language.PureScript.Pretty.Common Methods emit :: Text -> PlainString # addMapping :: SourceSpan -> PlainString #
Emit StrPos # |
Instance details Defined in Language.PureScript.Pretty.Common Methods emit :: Text -> StrPos # addMapping :: SourceSpan -> StrPos #

data SMap #

Constructors

SMap Text SourcePos SourcePos |

newtype StrPos #

String with length and source-map entries

Constructors

StrPos (SourcePos, Text, [SMap]) |

#### Instances

Instances details

Monoid StrPos # |
Instance details Defined in Language.PureScript.Pretty.Common Methods mempty :: StrPos # mappend :: StrPos -> StrPos -> StrPos # mconcat :: [StrPos] -> StrPos #
Semigroup StrPos # | 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.
Instance details Defined in Language.PureScript.Pretty.Common Methods (<>) :: StrPos -> StrPos -> StrPos # sconcat :: NonEmpty StrPos -> StrPos # stimes :: Integral b => b -> StrPos -> StrPos #
Emit StrPos # |
Instance details Defined in Language.PureScript.Pretty.Common Methods emit :: Text -> StrPos # addMapping :: SourceSpan -> StrPos #

newtype PlainString #

Constructors

PlainString Text |

#### Instances

Instances details

Monoid PlainString # |
Instance details Defined in Language.PureScript.Pretty.Common Methods mempty :: PlainString # mappend :: PlainString -> PlainString -> PlainString # mconcat :: [PlainString] -> PlainString #
Semigroup PlainString # |
Instance details Defined in Language.PureScript.Pretty.Common Methods (<>) :: PlainString -> PlainString -> PlainString # sconcat :: NonEmpty PlainString -> PlainString # stimes :: Integral b => b -> PlainString -> PlainString #
Emit PlainString # |
Instance details Defined in Language.PureScript.Pretty.Common Methods emit :: Text -> PlainString # addMapping :: SourceSpan -> PlainString #

runPlainString :: PlainString -> Text #

addMapping' :: Emit gen => Maybe SourceSpan -> gen #

bumpPos :: SourcePos -> SMap -> SMap #

addPos :: SourcePos -> SourcePos -> SourcePos #

data PrinterState #

Constructors

PrinterState |
Fields indent :: Int

blockIndent :: Int #

Number of characters per indentation level

withIndent :: StateT PrinterState Maybe gen -> StateT PrinterState Maybe gen #

Pretty print with a new indentation level

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

Get the current indentation level

objectKeyRequiresQuoting :: Text -> Bool #

before :: Box -> Box -> Box #

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

beforeWithSpace :: Box -> Box -> Box #

endWith :: Box -> Box -> Box #

Place a Box on the bottom right of another