cartel-0.16.0.0: Specify Cabal files in Haskell

Safe HaskellSafe
LanguageHaskell2010

Cartel.Render

Description

Reducing a Cartel AST to flat Cabal text; essentially a pretty-printer.

Synopsis

Documentation

(<+>) :: String -> String -> String Source

Separate two strings with a space, but only if both strings are not empty.

vsep :: [String] -> String Source

Concatenate several vertically. Unlike unlines, does not add a newline when an item is null or when the accumulator is null.

labeled Source

Arguments

:: String

Label

-> String

Value

-> String

Empty if value is empty; otherwise, the label with a colon and space appended, and the value

labeledIndented Source

Arguments

:: String

Label

-> String

Value

-> Reader Level String

Empty if value is empty; otherwise, the label with a colon and space appended, and the value, and a newline

type Level = Int Source

Indentation level

commaSeparated :: [String] -> [String] Source

Adds comma separators to a list.

indentConcat :: [String] -> Reader Level String Source

Indents list, adds newlines, and concats.

labeledList Source

Arguments

:: String

Label

-> [String]

List of items to show; if empty, return an empty string

-> Reader Level String 

escaper :: String -> String Source

Renders a string using show, but only if it is both non-empty and contains characters that might be problematic. For now, "might be problematic" simply means any character that is either above Unicode code point 7F or is not a letter, digit, hyphen, period, or underscore.

If the string is empty, or if it contains only non-problematic characters, returns the string as-is.

class RenderableIndented a where Source

Render an item. The rendered text must contain a newline at the end of each line and must end with a newline. The leftmost line of the rendered text shall be indented by the given number of indentation levels (the number of spaces in each level is set by indentAmt).

If there are no lines to indent, return an empty string.