Module ICurry.Pretty

This module contains a pretty printer for ICurry programs.

Author: Marc Andre Wittorf and Michael Hanus

Version: November 2020

Summary of exported operations:

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

Exported operations:

ppIProg :: IProg -> Doc  Deterministic 

Pretty print an ICurry module

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

ppHeader :: String -> Doc  Deterministic 

Pretty print an ICurry module header

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

ppImports :: [String] -> Doc  Deterministic 

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  Deterministic 

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  Deterministic 

Pretty print ICurry types

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

ppDataType :: IDataType -> Doc  Deterministic 

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  Deterministic 

Pretty print ICurry constructors

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

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

Pretty print an ICurry constructor

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

ppFunctions :: [IFunction] -> Doc  Deterministic 

Pretty print ICurry functions

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

ppFunction :: IFunction -> Doc  Deterministic 

Pretty print an ICurry function

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

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

Pretty print a qualified ICurry name (module.localname)

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

ppFuncBody :: IFuncBody -> Doc  Deterministic 

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  Deterministic 

Pretty print a list of variables

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

ppVar :: Int -> Doc  Deterministic 

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  Deterministic 

Pretty print an ICurry block

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

ppStatement :: IStatement -> Doc  Deterministic 

Pretty print an ICurry block

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

ppVarDecls :: [IVarDecl] -> Doc  Deterministic 

Pretty print local variable declarations

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

ppVarDecl :: IVarDecl -> Doc  Deterministic 

Pretty print a local variable declaration.

ppAssignments :: [IAssign] -> Doc  Deterministic 

Pretty print assignments

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

ppAssignment :: IAssign -> Doc  Deterministic 

Pretty print an assignment

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

ppExprs :: [IExpr] -> Doc  Deterministic 

Pretty print comma separated expressions

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

ppExpr :: IExpr -> Doc  Deterministic 

Pretty print an ICurry expression

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

ppConsBranches :: [IConsBranch] -> Doc  Deterministic 

Pretty print branches over constructors

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

ppConsBranch :: IConsBranch -> Doc  Deterministic 

Pretty print a branch over constructors

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

ppLitBranches :: [ILitBranch] -> Doc  Deterministic 

Pretty print branches over literals

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

ppLitBranch :: ILitBranch -> Doc  Deterministic 

Pretty print a branch over literals

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

ppPos :: [Int] -> Doc  Deterministic 

Pretty print an ICurry position

ppLit :: ILiteral -> Doc  Deterministic 

Pretty print an ICurry literal

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