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 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.

Minimal complete definition

renderIndented

Instances

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

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 Source # 
RenderableIndented Flags Source # 
RenderableIndented a => RenderableIndented (CondBlock a) Source # 

class Renderable a where Source #

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

Minimal complete definition

render

Methods

render :: a -> String Source #

Instances

Renderable Bool Source # 

Methods

render :: Bool -> String Source #

Renderable FlagName Source # 
Renderable Compiler Source # 
Renderable License Source # 
Renderable BuildType Source # 
Renderable BenchmarkType Source # 
Renderable TestSuiteType Source # 
Renderable DefaultLanguage Source # 
Renderable Package Source # 
Renderable Version Source # 
Renderable Condition Source # 
Renderable Constraint Source # 
Renderable ConstrTree Source # 
Renderable VersionComp Source # 
Renderable Logical Source # 
Renderable CondLeaf Source # 
Renderable Vcs Source # 

Methods

render :: Vcs -> String Source #

Renderable RepoKind Source # 
Renderable CabalVersion Source # 
Renderable a => Renderable (Maybe a) Source # 

Methods

render :: Maybe a -> String Source #

Renderable (Compiler, Constraint) Source # 

newtype Flags Source #

Constructors

Flags [Flag]