Module FlatCurry.Pretty

Author
Bjoern Peemoeller
Version
November 2020

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

Exported Datatypes


data 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

data 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 deriving Eq

Known instances:


Exported Functions


defaultOptions :: Options  Deterministic 

Default Options for pretty-printing.

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

ppProg :: Options -> Prog -> Doc  Deterministic 

pretty-print a FlatCurry module


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

pretty-print the module header


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

pretty-print the export list


ppTypeExport :: Options -> TypeDecl -> Doc  Deterministic 

pretty-print a type export

Further infos:
  • partially defined

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

pretty-print the export list of constructors


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

pretty-print the export list of functions


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

pretty-print a list of import statements


ppImport :: Options -> String -> Doc  Deterministic 

pretty-print a single import statement


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

pretty-print a list of operator fixity declarations


ppOpDecl :: Options -> OpDecl -> Doc  Deterministic 

pretty-print a single operator fixity declaration


ppFixity :: Fixity -> Doc  Deterministic 

pretty-print the associativity keyword

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

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

pretty-print a list of type declarations


ppTypeDecl :: Options -> TypeDecl -> Doc  Deterministic 

pretty-print a type declaration


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

pretty-print the constructor declarations


ppConsDecl :: Options -> ConsDecl -> Doc  Deterministic 

pretty print a single constructor


ppNewConsDecl :: Options -> NewConsDecl -> Doc  Deterministic 

pretty print a single newtype constructor


ppTypeExp :: Options -> TypeExpr -> Doc  Deterministic 

pretty a top-level type expression


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

pretty-print a type expression

Further infos:
  • partially defined

ppQuantifiedVars :: [(Int, Kind)] -> Doc  Deterministic 

pretty-print explicitly quantified type variables

Further infos:
  • partially defined

ppTVarIndex :: Int -> Doc  Deterministic 

pretty-print a type variable


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

pretty-print a list of function declarations


ppFuncDecl :: Options -> FuncDecl -> Doc  Deterministic 

pretty-print a function declaration


ppRule :: Options -> Rule -> Doc  Deterministic 

pretty-print a function rule

Further infos:
  • partially defined

ppExp :: Options -> Expr -> Doc  Deterministic 

Pretty-print a top-level expression.


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

pretty-print an expression

Further infos:
  • partially defined

ppVarIndex :: Int -> Doc  Deterministic 

pretty-print a variable

Further infos:
  • partially defined

ppLiteral :: Literal -> Doc  Deterministic 

pretty-print a literal


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

Pretty print a constructor or function call

Further infos:
  • partially defined

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

pretty-print a list of declarations


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

pretty-print a single declaration


ppCaseType :: CaseType -> Doc  Deterministic 

Pretty print the type of a case expression

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

ppBranch :: Options -> BranchExpr -> Doc  Deterministic 

Pretty print a case branch


ppPattern :: Options -> Pattern -> Doc  Deterministic 

Pretty print a pattern

Further infos:
  • partially defined

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

pretty-print a qualified prefix operator.


ppPrefixOp :: (String, String) -> Doc  Deterministic 

pretty-print a prefix operator unqualified.


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

pretty-print an infix operator


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

Pretty-print a qualified name


ppName :: (String, String) -> Doc  Deterministic 

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  Deterministic 

Check whether an operator is an infix operator


isConsId :: (String, String) -> Bool  Deterministic 

Check whether an identifier represents the : list constructor.


isListId :: (String, String) -> Bool  Deterministic 

Check whether an identifier represents a list


isTupleId :: (String, String) -> Bool  Deterministic 

Check whether an identifier represents a tuple


indent :: Options -> Doc -> Doc  Deterministic 

Indentation