Pretty-printing of AbstractCurry.
This library provides a pretty-printer for AbstractCurry modules.
Author: Yannik Potdevin (with changes by Michael Hanus)
Version: March 2016
defaultOptions
:: Options
The default options to pretty print a module. |
setPageWith
:: Int -> Options -> Options
Sets the page width of the pretty printer options. |
setIndentWith
:: Int -> Options -> Options
Sets the indentation width of the pretty printer options. |
setImportQualification
:: Options -> Options
Sets the qualification method to be used to print identifiers to "import qualification" (which is the default). |
setNoQualification
:: Options -> Options
Sets the qualification method to be used to print identifiers to "unqualified". |
setFullQualification
:: Options -> Options
Sets the qualification method to be used to print identifiers to "fully qualified". |
setOnDemandQualification
:: [CurryProg] -> Options -> Options
Sets the qualification method to be used to print identifiers to "qualification on demand". |
setModName
:: String -> Options -> Options
Sets the name of the current module in the pretty printer options. |
setLayoutChoice
:: LayoutChoice -> Options -> Options
Sets the preferred layout in the pretty printer options. |
showCProg
:: CurryProg -> String
Shows a pretty formatted version of an abstract Curry Program. |
prettyCurryProg
:: Options -> CurryProg -> String
Pretty-print the document generated by ppCurryProg , using the page width
specified by given options.
|
ppCurryProg
:: Options -> CurryProg -> Doc
Pretty-print a CurryProg (the representation of a program, written in Curry, using AbstractCurry) according to given options. |
ppMName
:: String -> Doc
Pretty-print a module name (just a string). |
ppExports
:: Options -> [CTypeDecl] -> [CFuncDecl] -> Doc
Pretty-print exports, i.e. |
ppImports
:: Options -> [String] -> Doc
Pretty-print imports (list of module names) by prepending the word "import" to the module name. |
ppCOpDecl
:: Options -> COpDecl -> Doc
Pretty-print operator precedence declarations. |
ppCTypeDecl
:: Options -> CTypeDecl -> Doc
Pretty-print type declarations, like `data ... |
ppCFuncDecl
:: Options -> CFuncDecl -> Doc
Pretty-print a function declaration. |
ppCFuncDeclWithoutSig
:: Options -> CFuncDecl -> Doc
Pretty-print a function declaration without signature. |
ppCFuncSignature
:: Options -> (String,String) -> CTypeExpr -> Doc
Pretty-print a function signature according to given options. |
ppCTypeExpr
:: Options -> CTypeExpr -> Doc
Pretty-print a type expression. |
ppCRules
:: Options -> (String,String) -> [CRule] -> Doc
Pretty-print a list of function rules, concatenated vertically. |
ppCRule
:: Options -> (String,String) -> CRule -> Doc
Pretty-print a rule of a function. |
ppCPattern
:: Options -> CPattern -> Doc
Pretty-print a pattern expression. |
ppCLiteral
:: Options -> CLiteral -> Doc
Pretty-print given literal (Int, Float, ...). |
ppCRhs
:: Doc -> Options -> CRhs -> Doc
Pretty-print the right hand side of a rule (or case expression), including the d sign, where d
is the relation (as doc) between the left hand side
and the right hand side -- usually this is one of = , -> .
|
ppCExpr
:: Options -> CExpr -> Doc
Pretty-print an expression. |
ppCStatement
:: Options -> CStatement -> Doc
|
ppQFunc
:: Options -> (String,String) -> Doc
Pretty-print a function name or constructor name qualified according to given options. |
ppFunc
:: (String,String) -> Doc
Pretty-print a function name or constructor name non-qualified. |
ppQType
:: Options -> (String,String) -> Doc
Pretty-print a type ( QName ) qualified according to given options.
|
ppType
:: (String,String) -> Doc
Pretty-print a type ( QName ) non-qualified.
|
Constructors:
The choice for a generally preferred layout.
Constructors:
PreferNestedLayout
:: LayoutChoice
: prefer a layout where the arguments of
long expressions are vertically aligned
PreferFilledLayout
:: LayoutChoice
: prefer a layout where the arguments of
long expressions are filled as long as possible
into one line
Constructors:
The default options to pretty print a module. These are:
These options can be changed by corresponding setters
(
Note: If these default options are used for pretty-print operations
other than
|
Sets the page width of the pretty printer options.
|
Sets the indentation width of the pretty printer options.
|
Sets the qualification method to be used to print identifiers to "import qualification" (which is the default). In this case, all identifiers imported from other modules (except for the identifiers of the prelude) are fully qualified.
|
Sets the qualification method to be used to print identifiers to "unqualified". In this case, no identifiers is printed with its module qualifier. This might lead to name conflicts or unintended references if some identifiers in the pretty-printed module are in conflict with imported identifiers.
|
Sets the qualification method to be used to print identifiers to "fully qualified". In this case, every identifiers, including those of the processed module and the prelude, are fully qualified.
|
Sets the qualification method to be used to print identifiers to "qualification on demand". In this case, an identifier is qualified only if it is necessary to avoid a name conflict, e.g., if a local identifier has the same names as an imported identifier. Since it is necessary to know the names of all identifiers defined in the current module (to be pretty printed) and imported from other modules, the first argument is the list of modules consisting of the current module and all imported modules (including the prelude). The current module must always be the head of this list. |
Sets the name of the current module in the pretty printer options.
|
Sets the preferred layout in the pretty printer options.
|
Shows a pretty formatted version of an abstract Curry Program.
The options for pretty-printing are the
|
Pretty-print the document generated by |
Pretty-print a CurryProg (the representation of a program, written in Curry,
using AbstractCurry) according to given options.
This function will overwrite the module name given by options
with the name specified as the first component of |
Pretty-print a module name (just a string).
|
Pretty-print exports, i.e. all type and function declarations which are public. extract the type and function declarations which are public and gather their qualified names in a list. |
Pretty-print imports (list of module names) by prepending the word "import"
to the module name. If the qualification mode is |
Pretty-print type declarations, like |
Pretty-print a function declaration. |
Pretty-print a function declaration without signature. |
Pretty-print a function signature according to given options. |
Pretty-print a type expression. |
Pretty-print a list of function rules, concatenated vertically. |
Pretty-print a rule of a function. Given a function
|
Pretty-print a pattern expression. |
Pretty-print given literal (Int, Float, ...). |
Pretty-print the right hand side of a rule (or case expression), including
the d sign, where |
|
Pretty-print a function name or constructor name qualified according to
given options. Use |
Pretty-print a function name or constructor name non-qualified.
Use |