cartel-0.18.0.2: 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 #

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

vsep :: [String] -> String #

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

labeled #

Arguments

:: String

Label

-> String

Value

-> String

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

labeledIndented #

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 #

Indentation level

commaSeparated :: [String] -> [String] #

Adds comma separators to a list.

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

Indents list, adds newlines, and concats.

labeledList #

Arguments

:: String

Label

-> [String]

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

-> Reader Level String 

escaper :: String -> String #

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 #

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.

Minimal complete definition

renderIndented

Instances

RenderableIndented FlagOpts # 
RenderableIndented Flag # 
RenderableIndented Error # 
RenderableIndented Cabal # 
RenderableIndented Properties # 
RenderableIndented Section # 
RenderableIndented Benchmark # 
RenderableIndented BenchmarkField # 
RenderableIndented TestSuite # 
RenderableIndented TestSuiteField # 
RenderableIndented Executable # 
RenderableIndented ExecutableField # 
RenderableIndented LibraryField # 
RenderableIndented BuildInfoField #

Contains many lists of items. Items that might contain spaces or other troublesome characters are rendered quoted. In particular, this includes filenames. Items that are highly unlikely to contain troublesome characters (such as compiler options) are not quoted.

RenderableIndented Repository # 
RenderableIndented Flags # 
RenderableIndented a => RenderableIndented (CondBlock a) # 

class Renderable a where #

Render an item. The rendered text shall contain no newlines.

Minimal complete definition

render

Methods

render :: a -> String #

newtype Flags #

Constructors

Flags [Flag] 

Instances