This library contains type definitions to represent ICurry programs.
type IQName
= (String, String, Int)
Each name in ICurry consists of the module name, the local name inside a module, and a number. For constructors, the number is the index of the constructors in the data type definition, i.e., all constructors of a data type are numbered from 0 (to support efficient switch statements for pattern matching). For functions, the number is unique inside a module so that functions can be efficiently accessed inside a module.
type IArity
= Int
An arity of ICurry functions and constructors is just an integer.
type IVarIndex
= Int
An ICurry variable is represented by a index which must be unique inside a function declaration.
data ILiteral
A literal occurring in expressions.
Constructors:
IInt
:: Int -> ILiteral
IChar
:: Char -> ILiteral
IFloat
:: Float -> ILiteral
Known instances:
data IProg
An ICurry module consists of a module name, the names of imported modules, and data type and function declarations.
Constructors:
Known instances:
data IDataType
An ICurry data type. Since type information is not relevant here, it is represented by the name of the data type together with all constructors names with their arities.
Constructors:
Known instances:
data IFunction
An ICurry function declaration consisting of the function's name, arity, visibility, the positions of always demandeded arguments (where 0 denotes the first argument), and a body. Note that the demanded arguments are definitely required to evaluate the function. In some situations (e.g., complex nested case statements), more arguments might be demanded.
Constructors:
IFunction
:: IQName -> IArity -> IVisibility -> [Int] -> IFuncBody -> IFunction
Known instances:
data IVisibility
The visibility of ICurry entities.
Constructors:
Public
:: IVisibility
Private
:: IVisibility
Known instances:
data IFuncBody
The body specifying the behavior of an ICurry function.
Constructors:
IExternal
:: String -> IFuncBody
IFuncBody
:: IBlock -> IFuncBody
Known instances:
data IBlock
An ICurry block. Each block consists of variable declarations, assignments, and a statement.
Constructors:
IBlock
:: [IVarDecl] -> [IAssign] -> IStatement -> IBlock
Known instances:
data IVarDecl
An ICurry variable declaration declares either a local variable or a free variable. In the subsequent assignments, graph nodes will be assigned to these variables. Instead of explicitly handling free variables, one could also use local variables and assign a node representing a value generator operation for this free variable. Since different implementations might use different strategies to deal with free variables, ICurry supports both options.
NOTE: The ICurry code assumes that the ICurry variable with index 0 always points to the root of the left-hand side when an ICurry function is invoked. This invariant must be ensured by the ICurry application!
Constructors:
Known instances:
data IAssign
An ICurry assignment is either an assignment to a local variable or an assignment to a successor of a node.
Constructors:
IVarAssign
:: IVarIndex -> IExpr -> IAssign
INodeAssign
:: IVarIndex -> [Int] -> IExpr -> IAssign
Known instances:
data IStatement
An ICurry statement. A return statement constructs a graph that replaces the current call. An exempt or failure statement terminates the current task. A case statement on constructors is assumed to be complete, i.e., there is a branch for each constructor of the type of the case argument. Furthermore, the branches should have the order of the constructors. For case statements on literals, there is no such restriction.
Constructors:
IExempt
:: IStatement
IReturn
:: IExpr -> IStatement
ICaseCons
:: IVarIndex -> [IConsBranch] -> IStatement
ICaseLit
:: IVarIndex -> [ILitBranch] -> IStatement
Known instances:
data IConsBranch
An ICurry case branch over algebraic constructors. Only the constructor and its arity matching this branch is given. The assignments of constructor arguments to pattern variables must be done in the ICurry block.
Constructors:
Known instances:
data ILitBranch
An ICurry case branch over literals.
Constructors:
Known instances:
data IExpr
An ICurry expression.
Constructors:
IVar
:: IVarIndex -> IExpr
IVarAccess
:: IVarIndex -> [Int] -> IExpr
ILit
:: ILiteral -> IExpr
IFCall
:: IQName -> [IExpr] -> IExpr
ICCall
:: IQName -> [IExpr] -> IExpr
IFPCall
:: IQName -> Int -> [IExpr] -> IExpr
ICPCall
:: IQName -> Int -> [IExpr] -> IExpr
IOr
:: IExpr -> IExpr -> IExpr
Known instances: