Module ICurry.Pretty

This module contains a pretty printer for ICurry programs.

Author: Marc Andre Wittorf and Michael Hanus

Version: June 2020

Summary of exported operations:

ppIProg :: IProg -> Doc   
Pretty print an ICurry module
ppHeader :: String -> Doc   
Pretty print an ICurry module header
ppImports :: [String] -> Doc   
Pretty print an ICurry module import list
ppImport :: String -> Doc   
Pretty print an import directive
ppDataTypes :: [IDataType] -> Doc   
Pretty print ICurry types
ppDataType :: IDataType -> Doc   
Pretty print an ICurry type
ppConstructors :: [((String,String,Int),Int)] -> Doc   
Pretty print ICurry constructors
ppConstructor :: ((String,String,Int),Int) -> Doc   
Pretty print an ICurry constructor
ppFunctions :: [IFunction] -> Doc   
Pretty print ICurry functions
ppFunction :: IFunction -> Doc   
Pretty print an ICurry function
ppQName :: (String,String,Int) -> Doc   
Pretty print a qualified ICurry name (module.localname)
ppFuncBody :: IFuncBody -> Doc   
Pretty print an ICurry function's body
ppVars :: [Int] -> Doc   
Pretty print a list of variables
ppVar :: Int -> Doc   
Pretty print a variable.
ppBlock :: IBlock -> Doc   
Pretty print an ICurry block
ppStatement :: IStatement -> Doc   
Pretty print an ICurry block
ppVarDecls :: [IVarDecl] -> Doc   
Pretty print local variable declarations
ppVarDecl :: IVarDecl -> Doc   
Pretty print a local variable declaration.
ppAssignments :: [IAssign] -> Doc   
Pretty print assignments
ppAssignment :: IAssign -> Doc   
Pretty print an assignment
ppExprs :: [IExpr] -> Doc   
Pretty print comma separated expressions
ppExpr :: IExpr -> Doc   
Pretty print an ICurry expression
ppConsBranches :: [IConsBranch] -> Doc   
Pretty print branches over constructors
ppConsBranch :: IConsBranch -> Doc   
Pretty print a branch over constructors
ppLitBranches :: [ILitBranch] -> Doc   
Pretty print branches over literals
ppLitBranch :: ILitBranch -> Doc   
Pretty print a branch over literals
ppPos :: [Int] -> Doc   
Pretty print an ICurry position
ppLit :: ILiteral -> Doc   
Pretty print an ICurry literal

Exported operations:

ppIProg :: IProg -> Doc   

Pretty print an ICurry module

Example call:
(ppIProg prog)
Parameters:
  • prog : the module
Returns:
the pretty printed module

ppHeader :: String -> Doc   

Pretty print an ICurry module header

Example call:
(ppHeader name)
Parameters:
  • name : the module name
Returns:
the pretty printed module header

ppImports :: [String] -> Doc   

Pretty print an ICurry module import list

Example call:
(ppImports names)
Parameters:
  • names : the imported modules' names
Returns:
the pretty printed import list

ppImport :: String -> Doc   

Pretty print an import directive

Example call:
(ppImport name)
Parameters:
  • name : the imported module's name
Returns:
the pretty printed module import directive

ppDataTypes :: [IDataType] -> Doc   

Pretty print ICurry types

Example call:
(ppDataTypes dts)
Parameters:
  • dts : the data type declarations
Returns:
the pretty printed types

ppDataType :: IDataType -> Doc   

Pretty print an ICurry type

Example call:
(ppDataType dt)
Parameters:
  • dt : the data type declaration
Returns:
the pretty printed type

ppConstructors :: [((String,String,Int),Int)] -> Doc   

Pretty print ICurry constructors

Example call:
(ppConstructors cs)
Parameters:
  • cs : the data constructors
Returns:
the pretty printed constructors

ppConstructor :: ((String,String,Int),Int) -> Doc   

Pretty print an ICurry constructor

Example call:
(ppConstructor c)
Parameters:
  • c : the data constructor
Returns:
the pretty printed constructor

ppFunctions :: [IFunction] -> Doc   

Pretty print ICurry functions

Example call:
(ppFunctions fns)
Parameters:
  • fns : the functions
Returns:
the pretty printed functions

ppFunction :: IFunction -> Doc   

Pretty print an ICurry function

Example call:
(ppFunction fns)
Parameters:
  • fns : the function
Returns:
the pretty printed function

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

Pretty print a qualified ICurry name (module.localname)

Example call:
(ppQName name)
Parameters:
  • name : the name
Returns:
the pretty printed name

ppFuncBody :: IFuncBody -> Doc   

Pretty print an ICurry function's body

Example call:
(ppFuncBody body)
Parameters:
  • body : the function's body
Returns:
the pretty printed function body

ppVars :: [Int] -> Doc   

Pretty print a list of variables

Example call:
(ppVars vs)
Parameters:
  • vs : the variables
Returns:
the pretty printed variables

ppVar :: Int -> Doc   

Pretty print a variable. Variables are called x0, x1, ... Since variable with index 0 is always used for the root, we print it as ROOT.

Example call:
(ppVar v)
Parameters:
  • v : the variable
Returns:
the pretty printed variable

ppBlock :: IBlock -> Doc   

Pretty print an ICurry block

Example call:
(ppBlock block)
Parameters:
  • block : the block
Returns:
the rendered block

ppStatement :: IStatement -> Doc   

Pretty print an ICurry block

Example call:
(ppStatement block)
Parameters:
  • block : the block
Returns:
the rendered block

ppVarDecls :: [IVarDecl] -> Doc   

Pretty print local variable declarations

Example call:
(ppVarDecls vs)
Parameters:
  • vs : the local variables
Returns:
the pretty printed variable declarations

ppVarDecl :: IVarDecl -> Doc   

Pretty print a local variable declaration.

ppAssignments :: [IAssign] -> Doc   

Pretty print assignments

Example call:
(ppAssignments as)
Parameters:
  • as : the assignments
Returns:
the pretty printed assignments

ppAssignment :: IAssign -> Doc   

Pretty print an assignment

Example call:
(ppAssignment as)
Parameters:
  • as : the assignment
Returns:
the pretty printed assignment

ppExprs :: [IExpr] -> Doc   

Pretty print comma separated expressions

Example call:
(ppExprs exprs)
Parameters:
  • exprs : the expressions
Returns:
the pretty printed expressions

ppExpr :: IExpr -> Doc   

Pretty print an ICurry expression

Example call:
(ppExpr expr)
Parameters:
  • expr : the expression
Returns:
the pretty printed expression

ppConsBranches :: [IConsBranch] -> Doc   

Pretty print branches over constructors

Example call:
(ppConsBranches bs)
Parameters:
  • bs : the branches
Returns:
the pretty printed branches

ppConsBranch :: IConsBranch -> Doc   

Pretty print a branch over constructors

Example call:
(ppConsBranch b)
Parameters:
  • b : the branch
Returns:
the pretty printed branch

ppLitBranches :: [ILitBranch] -> Doc   

Pretty print branches over literals

Example call:
(ppLitBranches bs)
Parameters:
  • bs : the branches
Returns:
the pretty printed branches

ppLitBranch :: ILitBranch -> Doc   

Pretty print a branch over literals

Example call:
(ppLitBranch b)
Parameters:
  • b : the branch
Returns:
the pretty printed branch

ppPos :: [Int] -> Doc   

Pretty print an ICurry position

ppLit :: ILiteral -> Doc   

Pretty print an ICurry literal

Example call:
(ppLit lit)
Parameters:
  • lit : the literal
Returns:
the pretty printed literal