Module ICurry.InferNeededTypeArgs

Infer type arguments required to properly know the types of free variables

Author: Marc Andre Wittorf

Summary of exported operations:

usedImportsExp :: [((String,String),(TypeExpr,[Int]))] -> AExpr TypeExpr -> [Int]   
Find all type variables used for free variables in an expression
unifyTypes :: TypeExpr -> TypeExpr -> [(Int,TypeExpr)]   
Unify two types
findNeededImports :: [((String,String),(TypeExpr,[Int]))] -> AProg TypeExpr -> [((String,String),(TypeExpr,[Int]))]   

Infer type arguments a function needs for all functions in a modules

This function iterates over all functions until it has reached a fixpoint, so it even finds a correct solution for mutually recursive function calls

Exported operations:

usedImportsExp :: [((String,String),(TypeExpr,[Int]))] -> AExpr TypeExpr -> [Int]   

Find all type variables used for free variables in an expression

Example call:
(usedImportsExp ms expr)
Parameters:
  • ms : the known type requirements
  • expr : the expression
Returns:
the required type arguments

unifyTypes :: TypeExpr -> TypeExpr -> [(Int,TypeExpr)]   

Unify two types

Example call:
(unifyTypes tl1 tl2)
Parameters:
  • tl1 : a type expression
  • tl2 : another type expression
Returns:
a unifier. tl1's variables will be assigned to tyexps from tl2

findNeededImports :: [((String,String),(TypeExpr,[Int]))] -> AProg TypeExpr -> [((String,String),(TypeExpr,[Int]))]   

Infer type arguments a function needs for all functions in a modules

This function iterates over all functions until it has reached a fixpoint, so it even finds a correct solution for mutually recursive function calls

Example call:
(findNeededImports ms prog)
Parameters:
  • ms : known needed type arguments for all imported modules
  • prog : the module
Returns:
needed type argument mappings for all functions in this module