Module FlatCurry.Pretty

This library provides pretty-printers for FlatCurry modules and all substructures (e.g., expressions).

Author: Bjoern Peemoeller

Version: June 2015

Summary of exported operations:

defaultOptions :: Options   
Default Options for pretty-printing.
ppProg :: Options -> Prog -> Doc   
pretty-print a FlatCurry module
ppHeader :: Options -> String -> [TypeDecl] -> [FuncDecl] -> Doc   
pretty-print the module header
ppExports :: Options -> [TypeDecl] -> [FuncDecl] -> Doc   
pretty-print the export list
ppTypeExport :: Options -> TypeDecl -> Doc   
pretty-print a type export
ppConsExports :: Options -> [ConsDecl] -> [Doc]   
pretty-print the export list of constructors
ppFuncExports :: Options -> [FuncDecl] -> [Doc]   
pretty-print the export list of functions
ppImports :: Options -> [String] -> Doc   
pretty-print a list of import statements
ppImport :: Options -> String -> Doc   
pretty-print a single import statement
ppOpDecls :: Options -> [OpDecl] -> Doc   
pretty-print a list of operator fixity declarations
ppOpDecl :: Options -> OpDecl -> Doc   
pretty-print a single operator fixity declaration
ppFixity :: Fixity -> Doc   
pretty-print the associativity keyword
ppTypeDecls :: Options -> [TypeDecl] -> Doc   
pretty-print a list of type declarations
ppTypeDecl :: Options -> TypeDecl -> Doc   
pretty-print a type declaration
ppConsDecls :: Options -> [ConsDecl] -> Doc   
pretty-print the constructor declarations
ppConsDecl :: Options -> ConsDecl -> Doc   
pretty print a single constructor
ppTypeExp :: Options -> TypeExpr -> Doc   
pretty a top-level type expression
ppTypeExpr :: Options -> Int -> TypeExpr -> Doc   
pretty-print a type expression
ppTVarIndex :: Int -> Doc   
pretty-print a type variable
ppFuncDecls :: Options -> [FuncDecl] -> Doc   
pretty-print a list of function declarations
ppFuncDecl :: Options -> FuncDecl -> Doc   
pretty-print a function declaration
ppRule :: Options -> Rule -> Doc   
pretty-print a function rule
ppExp :: Options -> Expr -> Doc   
Pretty-print a top-level expression.
ppExpr :: Options -> Int -> Expr -> Doc   
pretty-print an expression
ppVarIndex :: Int -> Doc   
pretty-print a variable
ppLiteral :: Literal -> Doc   
pretty-print a literal
ppComb :: Options -> Int -> (String,String) -> [Expr] -> Doc   
Pretty print a constructor or function call
ppDecls :: Options -> [(Int,Expr)] -> Doc   
pretty-print a list of declarations
ppDecl :: Options -> (Int,Expr) -> Doc   
pretty-print a single declaration
ppCaseType :: CaseType -> Doc   
Pretty print the type of a case expression
ppBranch :: Options -> BranchExpr -> Doc   
Pretty print a case branch
ppPattern :: Options -> Pattern -> Doc   
Pretty print a pattern
ppPrefixQOp :: Options -> (String,String) -> Doc   
pretty-print a qualified prefix operator.
ppPrefixOp :: (String,String) -> Doc   
pretty-print a prefix operator unqualified.
ppInfixQOp :: Options -> (String,String) -> Doc   
pretty-print an infix operator
ppQName :: Options -> (String,String) -> Doc   
Pretty-print a qualified name
ppName :: (String,String) -> Doc   
Pretty-print a qualified name unqualified (e.g., for type definitions).
isInfixOp :: (String,String) -> Bool   
Check whether an operator is an infix operator
isConsId :: (String,String) -> Bool   
Check whether an identifier represents the : list constructor.
isListId :: (String,String) -> Bool   
Check whether an identifier represents a list
isTupleId :: (String,String) -> Bool   
Check whether an identifier represents a tuple
indent :: Options -> Doc -> Doc   
Indentation

Exported datatypes:


Options

Options for pretty printing

Constructors:

  • Options :: Int -> QualMode -> String -> Options

    Fields:

    • indentWidth :: Int : number of columns for indentation of substructures
    • qualMode :: QualMode : Qualification mode of pretty printer
    • currentModule :: String : Name of current module to be pretty-printed, used for proper qualification

QualMode

Qualification mode, determines whether identifiers are printed qualified or unqualified. While QualNone and QualImports aim at readability, there may be ambiguities due to shadowing. On the contrary, QualImports and QualAll produce correct output at the cost of readability.

Constructors:

  • QualNone :: QualMode : no qualification, only unqualified names
  • QualImportsButPrelude :: QualMode : qualify all imports except those from the module Prelude
  • QualImports :: QualMode : qualify all imports, including Prelude
  • QualAll :: QualMode : qualify all names

Exported operations:

defaultOptions :: Options   

Default Options for pretty-printing.

Further infos:
  • solution complete, i.e., able to compute all solutions

ppProg :: Options -> Prog -> Doc   

pretty-print a FlatCurry module

ppHeader :: Options -> String -> [TypeDecl] -> [FuncDecl] -> Doc   

pretty-print the module header

ppExports :: Options -> [TypeDecl] -> [FuncDecl] -> Doc   

pretty-print the export list

ppTypeExport :: Options -> TypeDecl -> Doc   

pretty-print a type export

ppConsExports :: Options -> [ConsDecl] -> [Doc]   

pretty-print the export list of constructors

ppFuncExports :: Options -> [FuncDecl] -> [Doc]   

pretty-print the export list of functions

ppImports :: Options -> [String] -> Doc   

pretty-print a list of import statements

ppImport :: Options -> String -> Doc   

pretty-print a single import statement

ppOpDecls :: Options -> [OpDecl] -> Doc   

pretty-print a list of operator fixity declarations

ppOpDecl :: Options -> OpDecl -> Doc   

pretty-print a single operator fixity declaration

ppFixity :: Fixity -> Doc   

pretty-print the associativity keyword

Further infos:
  • solution complete, i.e., able to compute all solutions

ppTypeDecls :: Options -> [TypeDecl] -> Doc   

pretty-print a list of type declarations

ppTypeDecl :: Options -> TypeDecl -> Doc   

pretty-print a type declaration

ppConsDecls :: Options -> [ConsDecl] -> Doc   

pretty-print the constructor declarations

ppConsDecl :: Options -> ConsDecl -> Doc   

pretty print a single constructor

ppTypeExp :: Options -> TypeExpr -> Doc   

pretty a top-level type expression

ppTypeExpr :: Options -> Int -> TypeExpr -> Doc   

pretty-print a type expression

ppTVarIndex :: Int -> Doc   

pretty-print a type variable

ppFuncDecls :: Options -> [FuncDecl] -> Doc   

pretty-print a list of function declarations

ppFuncDecl :: Options -> FuncDecl -> Doc   

pretty-print a function declaration

ppRule :: Options -> Rule -> Doc   

pretty-print a function rule

ppExp :: Options -> Expr -> Doc   

Pretty-print a top-level expression.

ppExpr :: Options -> Int -> Expr -> Doc   

pretty-print an expression

ppVarIndex :: Int -> Doc   

pretty-print a variable

ppLiteral :: Literal -> Doc   

pretty-print a literal

ppComb :: Options -> Int -> (String,String) -> [Expr] -> Doc   

Pretty print a constructor or function call

ppDecls :: Options -> [(Int,Expr)] -> Doc   

pretty-print a list of declarations

ppDecl :: Options -> (Int,Expr) -> Doc   

pretty-print a single declaration

ppCaseType :: CaseType -> Doc   

Pretty print the type of a case expression

Further infos:
  • solution complete, i.e., able to compute all solutions

ppBranch :: Options -> BranchExpr -> Doc   

Pretty print a case branch

ppPattern :: Options -> Pattern -> Doc   

Pretty print a pattern

ppPrefixQOp :: Options -> (String,String) -> Doc   

pretty-print a qualified prefix operator.

ppPrefixOp :: (String,String) -> Doc   

pretty-print a prefix operator unqualified.

ppInfixQOp :: Options -> (String,String) -> Doc   

pretty-print an infix operator

ppQName :: Options -> (String,String) -> Doc   

Pretty-print a qualified name

ppName :: (String,String) -> Doc   

Pretty-print a qualified name unqualified (e.g., for type definitions).

Further infos:
  • solution complete, i.e., able to compute all solutions

isInfixOp :: (String,String) -> Bool   

Check whether an operator is an infix operator

isConsId :: (String,String) -> Bool   

Check whether an identifier represents the : list constructor.

isListId :: (String,String) -> Bool   

Check whether an identifier represents a list

isTupleId :: (String,String) -> Bool   

Check whether an identifier represents a tuple

indent :: Options -> Doc -> Doc   

Indentation