This library contains a definition for representing Haskell programs in Curry (type "Prog").
Author: Michael Hanus, Björn Peemöller
Version: May 2017
Data type for representing a Haskell module in the intermediate form. A value of this data type has the form
(CProg modname imports typedecls functions opdecls)
where modname: name of this module, imports: list of modules names that are imported, typedecls, opdecls, functions: see below
Constructors:
The data type for representing qualified names. In AbstractHaskell all names are qualified to avoid name clashes. The first component is the module name and the second component the unqualified name as it occurs in the source program.
Type synonym: QName = (String,String)
Data type to specify the visibility of various entities.
Constructors:
Public
:: Visibility
Private
:: Visibility
The data type for representing type variables. They are represented by (i,n) where i is a type variable index which is unique inside a function and n is a name (if possible, the name written in the source program).
Type synonym: TVarIName = (Int,String)
Data type for representing definitions of algebraic data types and type synonyms.
A data type definition of the form
data t x1...xn = ...| c t1....tkc |...
is represented by the Curry term
(Type t v [i1,...,in] [...(ons c kc v [t1,...,tkc])...])
where each ij
is the index of the type variable xj
.
Note: the type variable indices are unique inside each type declaration and are usually numbered from 0
Thus, a data type declaration consists of the name of the data type, a list of type parameters and a list of constructor declarations.
Constructors:
Type
:: QName -> Visibility -> [TVarIName] -> [ConsDecl] -> TypeDecl
TypeSyn
:: QName -> Visibility -> [TVarIName] -> TypeExpr -> TypeDecl
TypeNew
:: QName -> Visibility -> [TVarIName] -> NewConsDecl -> TypeDecl
Instance
:: QName -> TypeExpr -> [Context] -> [(QName,Rule)] -> TypeDecl
A single type context is class name applied to type variables.
Constructors:
A constructor declaration consists of the name and arity of the constructor and a list of the argument types of the constructor.
Constructors:
Cons
:: QName -> Int -> Visibility -> [TypeExpr] -> ConsDecl
A constructor declaration for a newtype consists of the name of the constructor and the argument type of the constructor.
Constructors:
NewCons
:: QName -> Visibility -> TypeExpr -> NewConsDecl
Data type for type expressions. A type expression is either a type variable, a function type, or a type constructor application.
Note: the names of the predefined type constructors are "Int", "Float", "Bool", "Char", "IO", "()" (unit type), "(,...,)" (tuple types), "[]" (list type)
Constructors:
TVar
:: TVarIName -> TypeExpr
FuncType
:: TypeExpr -> TypeExpr -> TypeExpr
TCons
:: QName -> [TypeExpr] -> TypeExpr
ForallType
:: [(TVarIName,Kind)] -> [Context] -> TypeExpr -> TypeExpr
Constructors:
Data type to represent the type signature of a defined function. The type can be missing or a type with an optional context.
Constructors:
Data type for operator declarations. An operator declaration "fix p n" in Haskell corresponds to the AbstractHaskell term (Op n fix p).
Constructors:
Constructors:
InfixOp
:: Fixity
InfixlOp
:: Fixity
InfixrOp
:: Fixity
Data types for representing object variables. Object variables occurring in expressions are represented by (Var i) where i is a variable index.
Type synonym: VarIName = (Int,String)
Data type for representing function declarations.
A function declaration in AbstractHaskell is a term of the form
(Func cmt name arity visibility type (Rules eval [Rule rule1,...,rulek]))
and represents the function name
defined by the rules rule1,...,rulek
.
Note: the variable indices are unique inside each rule
External functions are represented as
(Func cmt name arity type External)
Thus, a function declaration consists of the comment, name, arity, type, and a list of rules. The type is optional according to its occurrence in the source text. The comment could be used by pretty printers that generate a readable Haskell program containing documentation comments.
Constructors:
Func
:: String -> QName -> Int -> Visibility -> TypeSig -> Rules -> FuncDecl
Rules are either a list of single rules or no rule at all if then function is defined externally.
Constructors:
Rules
:: [Rule] -> Rules
External
:: Rules
The most general form of a rule. It consists of a list of patterns (left-hand side), a list of guards ("True" if not present in the source text) with their corresponding right-hand sides, and a list of local declarations.
Constructors:
Constructors:
Data type for representing local (let/where) declarations
Constructors:
Data type for representing Haskell expressions.
Constructors:
Var
:: VarIName -> Expr
Lit
:: Literal -> Expr
Symbol
:: QName -> Expr
Apply
:: Expr -> Expr -> Expr
InfixApply
:: Expr -> QName -> Expr -> Expr
Lambda
:: [Pattern] -> Expr -> Expr
Let
:: [LocalDecl] -> Expr -> Expr
DoExpr
:: [Statement] -> Expr
ListComp
:: Expr -> [Statement] -> Expr
Case
:: Expr -> [BranchExpr] -> Expr
Typed
:: Expr -> TypeExpr -> Expr
IfThenElse
:: Expr -> Expr -> Expr -> Expr
Tuple
:: [Expr] -> Expr
List
:: [Expr] -> Expr
Data type for representing statements in do expressions and list comprehensions.
Constructors:
Data type for representing pattern expressions.
Constructors:
PVar
:: VarIName -> Pattern
PLit
:: Literal -> Pattern
PComb
:: QName -> [Pattern] -> Pattern
PAs
:: VarIName -> Pattern -> Pattern
PTuple
:: [Pattern] -> Pattern
PList
:: [Pattern] -> Pattern
Data type for representing branches in case expressions.
Constructors:
Data type for representing literals occurring in an expression. It is either an integer, a float, a character, or a string constant.
Constructors:
Intc
:: Int -> Literal
Floatc
:: Float -> Literal
Charc
:: Char -> Literal
Stringc
:: String -> Literal