Module CurryInterface.Pretty

This library provides a pretty-printer for Curry interfaces.

Version: September 2024

Summary of exported operations:

defaultOptions :: Options  Deterministic 
The default options for pretty printing: show everything
ppInterface :: Options -> Interface -> Doc  Deterministic 
pretty-print a Curry interface
ppModuleIdent :: Options -> ModuleIdent -> Doc  Deterministic 
pretty-print a ModuleIdent
ppImportDecl :: Options -> IImportDecl -> Doc  Deterministic 
pretty-print an import declaration
ppDecl :: Options -> IDecl -> Doc  Deterministic 
pretty-print a declaration
ppFunDeps :: Options -> [FunDep] -> Doc  Deterministic 
ppArity :: Options -> Int -> Doc  Deterministic 
pretty-print an arity
ppPrecedence :: Options -> Int -> Doc  Deterministic 
pretty-print a precedence
ppInfix :: Options -> Infix -> Doc  Deterministic 
pretty-print an infix declaration
ppIdent :: Options -> Int -> Ident -> Doc  Deterministic 
Pretty-print an Ident.
ppQualIdent :: Options -> Int -> QualIdent -> Doc  Deterministic 
pretty-print a QualIdent
ppWithOptionalKind :: Options -> QualIdent -> Maybe KindExpr -> Doc  Deterministic 
pretty-print a QualIdent with an optional kind expression
ppTypeVariable :: Options -> Ident -> Doc  Deterministic 
pretty-print a type variable
ppTypeVariables :: Options -> [Ident] -> Doc  Deterministic 
pretty-print a list of type variables
ppNewConstructor :: Options -> NewConstrDecl -> Doc  Deterministic 
pretty-print a newtype constructor declaration
ppConstructor :: Options -> ConstrDecl -> Doc  Deterministic 
pretty-print a constructor declaration
ppConstructors :: Options -> [ConstrDecl] -> Doc  Deterministic 
pretty-print a list of constructor declarations
ppField :: Options -> FieldDecl -> Doc  Deterministic 
pretty-print a field declaration
ppFields :: Options -> [FieldDecl] -> Doc  Deterministic 
pretty-print a list of field declarations
ppModulePragma :: Options -> ModuleIdent -> Doc  Deterministic 
pretty-print a module pragma
ppHiddenPragma :: Options -> [Ident] -> Doc  Deterministic 
pretty-print a hidden pragma
ppMethodPragma :: Options -> Ident -> Doc  Deterministic 
pretty-print a method pragma
ppType :: Options -> Int -> TypeExpr -> Doc  Deterministic 
pretty-print a type declaration
ppQualType :: Options -> QualTypeExpr -> Doc  Deterministic 
pretty-print a QualType
ppConstraint :: Options -> Constraint -> Doc  Deterministic 
pretty-print a constraint
ppContext :: Options -> [Constraint] -> Doc  Deterministic 
pretty-print a context
ppMethodDecl :: Options -> IMethodDecl -> Doc  Deterministic 
pretty-print a method declaration
ppMethodDecls :: Options -> [IMethodDecl] -> Doc  Deterministic 
pretty-print a list of method declarations
ppInstance :: Options -> [TypeExpr] -> Doc  Deterministic 
pretty-print an instance
ppImplementation :: Options -> (Ident,Int) -> Doc  Deterministic 
pretty-print a method implementation
ppImplementations :: Options -> [(Ident,Int)] -> Doc  Deterministic 
pretty-print a list of method implementations
ppKindExpr :: Options -> Int -> KindExpr -> Doc  Deterministic 
pretty-print a kind expression
ppMaybe :: (a -> Doc) -> Maybe a -> Doc  Deterministic 
HELPER FUNCTIONS pretty-print Just as normal, Nothing as empty
isOperator :: String -> Bool  Deterministic 
Check if string is an operator
lpragma :: Doc  Deterministic 
pretty-print "{-#"
rpragma :: Doc  Deterministic 
pretty-print "-#}"
preludeCharType :: TypeExpr  Deterministic 
Prelude.Char type.
localCharType :: TypeExpr  Deterministic 
Local Char type.
isInstanceOf :: QualIdent -> IDecl -> Bool  Deterministic 
Checks if an instance of some type class is defined for a given identifier.
funOfApply :: TypeExpr -> Maybe QualIdent  Deterministic 

Exported datatypes:


Options

Options to influence the pretty printing of Curry interfaces.

Constructors:

  • Options :: String -> [IDecl] -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> Options

    Fields:

    • optModule :: String
    • optInstances :: [IDecl]
    • optQualify :: Bool
    • optWithString :: Bool
    • optWithArity :: Bool
    • optWithHiding :: Bool
    • optWithInstance :: Bool
    • optWithImports :: Bool
    • optWithKinds :: Bool
    • optIndent :: Int
    • optHelp :: Bool

Exported operations:

defaultOptions :: Options  Deterministic 

The default options for pretty printing: show everything

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

ppInterface :: Options -> Interface -> Doc  Deterministic 

pretty-print a Curry interface

ppModuleIdent :: Options -> ModuleIdent -> Doc  Deterministic 

pretty-print a ModuleIdent

ppImportDecl :: Options -> IImportDecl -> Doc  Deterministic 

pretty-print an import declaration

ppDecl :: Options -> IDecl -> Doc  Deterministic 

pretty-print a declaration

Further infos:
  • partially defined

ppFunDeps :: Options -> [FunDep] -> Doc  Deterministic 

Further infos:
  • partially defined

ppArity :: Options -> Int -> Doc  Deterministic 

pretty-print an arity

ppPrecedence :: Options -> Int -> Doc  Deterministic 

pretty-print a precedence

ppInfix :: Options -> Infix -> Doc  Deterministic 

pretty-print an infix declaration

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

ppIdent :: Options -> Int -> Ident -> Doc  Deterministic 

Pretty-print an Ident. If the second argument is non-zero, operators (i.e., strings with special characters) will be enclosed in parentheses.

ppQualIdent :: Options -> Int -> QualIdent -> Doc  Deterministic 

pretty-print a QualIdent

Further infos:
  • partially defined

ppWithOptionalKind :: Options -> QualIdent -> Maybe KindExpr -> Doc  Deterministic 

pretty-print a QualIdent with an optional kind expression

Further infos:
  • partially defined

ppTypeVariable :: Options -> Ident -> Doc  Deterministic 

pretty-print a type variable

ppTypeVariables :: Options -> [Ident] -> Doc  Deterministic 

pretty-print a list of type variables

ppNewConstructor :: Options -> NewConstrDecl -> Doc  Deterministic 

pretty-print a newtype constructor declaration

ppConstructor :: Options -> ConstrDecl -> Doc  Deterministic 

pretty-print a constructor declaration

ppConstructors :: Options -> [ConstrDecl] -> Doc  Deterministic 

pretty-print a list of constructor declarations

ppField :: Options -> FieldDecl -> Doc  Deterministic 

pretty-print a field declaration

ppFields :: Options -> [FieldDecl] -> Doc  Deterministic 

pretty-print a list of field declarations

ppModulePragma :: Options -> ModuleIdent -> Doc  Deterministic 

pretty-print a module pragma

ppHiddenPragma :: Options -> [Ident] -> Doc  Deterministic 

pretty-print a hidden pragma

ppMethodPragma :: Options -> Ident -> Doc  Deterministic 

pretty-print a method pragma

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

pretty-print a type declaration

Further infos:
  • partially defined

ppQualType :: Options -> QualTypeExpr -> Doc  Deterministic 

pretty-print a QualType

ppConstraint :: Options -> Constraint -> Doc  Deterministic 

pretty-print a constraint

ppContext :: Options -> [Constraint] -> Doc  Deterministic 

pretty-print a context

ppMethodDecl :: Options -> IMethodDecl -> Doc  Deterministic 

pretty-print a method declaration

ppMethodDecls :: Options -> [IMethodDecl] -> Doc  Deterministic 

pretty-print a list of method declarations

ppInstance :: Options -> [TypeExpr] -> Doc  Deterministic 

pretty-print an instance

ppImplementation :: Options -> (Ident,Int) -> Doc  Deterministic 

pretty-print a method implementation

ppImplementations :: Options -> [(Ident,Int)] -> Doc  Deterministic 

pretty-print a list of method implementations

ppKindExpr :: Options -> Int -> KindExpr -> Doc  Deterministic 

pretty-print a kind expression

ppMaybe :: (a -> Doc) -> Maybe a -> Doc  Deterministic 

HELPER FUNCTIONS pretty-print Just as normal, Nothing as empty

isOperator :: String -> Bool  Deterministic 

Check if string is an operator

lpragma :: Doc  Deterministic 

pretty-print "{-#"

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

rpragma :: Doc  Deterministic 

pretty-print "-#}"

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

preludeCharType :: TypeExpr  Deterministic 

Prelude.Char type.

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

localCharType :: TypeExpr  Deterministic 

Local Char type.

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

isInstanceOf :: QualIdent -> IDecl -> Bool  Deterministic 

Checks if an instance of some type class is defined for a given identifier.

This function is used to determine whether the deriving clause of a data declaration should be shown. If the instance of the type class is defined locally, it is shown; otherwise, it is not shown.

Note that this only makes sense for type classes with a single type parameter.

funOfApply :: TypeExpr -> Maybe QualIdent  Deterministic