Module FlatCurry.AddTypes

This module implements a transformation on FlatCurry programs which adds Typed expressions to variables/function/constructor calls.

Author: Michael Hanus

Version: March 2024

Summary of exported operations:

testAddTypes :: String -> IO ()  Non-deterministic 
testAddTypesWithProgs :: String -> [(String,ModInfo)] -> IO ()  Deterministic 
addTypes2FuncDecls :: [(String,ModInfo)] -> [FuncDecl] -> [FuncDecl]  Deterministic 
addTypes2VarExp :: [(String,ModInfo)] -> [(Int,TypeExpr)] -> Expr -> TypeExpr -> Expr  Deterministic 
defaultAddTypeOptsAll :: AddTypeOpts  Deterministic 
defaultAddTypeOptsPoly :: AddTypeOpts  Deterministic 
transInfoFrom :: [(String,ModInfo)] -> AddTypeOpts -> TransInfo  Deterministic 
getProgInfoFor :: String -> String -> StateT TransInfo Identity ModInfo  Deterministic 
newFreshTVar :: StateT TransInfo Identity Int  Deterministic 
getVarType :: Int -> StateT TransInfo Identity TypeExpr  Deterministic 
addVarTypes :: [(Int,TypeExpr)] -> StateT TransInfo Identity ()  Deterministic 
applyCurrTSubst :: TypeExpr -> StateT TransInfo Identity TypeExpr  Deterministic 
addTVarBind :: Int -> TypeExpr -> StateT TransInfo Identity ()  Deterministic 
unifyTypes :: TypeExpr -> TypeExpr -> StateT TransInfo Identity ()  Deterministic 
typedExp :: (AddTypeOpts -> Bool) -> Expr -> TypeExpr -> StateT TransInfo Identity Expr  Deterministic 
addType2Exp :: Expr -> TypeExpr -> Expr  Deterministic 
addTypes2Module :: String -> StateT TransInfo Identity Prog  Deterministic 
addTypes2Func :: FuncDecl -> StateT TransInfo Identity FuncDecl  Deterministic 
addTypes2Rule :: [(Int,TypeExpr)] -> Expr -> TypeExpr -> StateT TransInfo Identity Expr  Deterministic 
addTypes2Expr :: TypeExpr -> Expr -> StateT TransInfo Identity Expr  Deterministic 
splitArgTypes :: Int -> TypeExpr -> ([TypeExpr],TypeExpr)  Deterministic 
Splits a possibly functional type into types of arguments and result w.r.t.
freshTypeVariant :: TypeExpr -> StateT TransInfo Identity TypeExpr  Deterministic 
getCombTypeOf :: CombType -> (String,String) -> StateT TransInfo Identity TypeExpr  Deterministic 
getFuncTypeOf :: (String,String) -> StateT TransInfo Identity TypeExpr  Deterministic 
getConsTypeOf :: (String,String) -> StateT TransInfo Identity TypeExpr  Deterministic 
applyTSubst :: [(Int,TypeExpr)] -> TypeExpr -> TypeExpr  Deterministic 
applyTSubst2Exp :: [(Int,TypeExpr)] -> Expr -> Expr  Deterministic 
allTVarsInFuncDecl :: FuncDecl -> [Int]  Deterministic 
allTVarsInTExp :: TypeExpr -> [Int]  Deterministic 
allTVarsInExp :: Expr -> [Int]  Deterministic 
allTVarsInTDecl :: TypeDecl -> [Int]  Deterministic 

Exported datatypes:


TransInfo

Constructors:


AddTypeOpts

Constructors:

  • AddTypeOpts :: Bool -> Bool -> Bool -> Bool -> AddTypeOpts

    Fields:

    • optAddVarType :: Bool
    • optAddLitType :: Bool
    • optAddCombType :: Bool
    • optAddPolyType :: Bool

TransState

Type synonym: TransState a = State TransInfo a


TSubst

Type synonym: TSubst = [(Int,TypeExpr)]


Exported operations:

testAddTypes :: String -> IO ()  Non-deterministic 

testAddTypesWithProgs :: String -> [(String,ModInfo)] -> IO ()  Deterministic 

addTypes2FuncDecls :: [(String,ModInfo)] -> [FuncDecl] -> [FuncDecl]  Deterministic 

addTypes2VarExp :: [(String,ModInfo)] -> [(Int,TypeExpr)] -> Expr -> TypeExpr -> Expr  Deterministic 

defaultAddTypeOptsAll :: AddTypeOpts  Deterministic 

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

defaultAddTypeOptsPoly :: AddTypeOpts  Deterministic 

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

transInfoFrom :: [(String,ModInfo)] -> AddTypeOpts -> TransInfo  Deterministic 

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

getProgInfoFor :: String -> String -> StateT TransInfo Identity ModInfo  Deterministic 

addVarTypes :: [(Int,TypeExpr)] -> StateT TransInfo Identity ()  Deterministic 

addTVarBind :: Int -> TypeExpr -> StateT TransInfo Identity ()  Deterministic 

addType2Exp :: Expr -> TypeExpr -> Expr  Deterministic 

splitArgTypes :: Int -> TypeExpr -> ([TypeExpr],TypeExpr)  Deterministic 

Splits a possibly functional type into types of arguments and result w.r.t. a given arity.

Further infos:
  • partially defined

getCombTypeOf :: CombType -> (String,String) -> StateT TransInfo Identity TypeExpr  Deterministic 

getFuncTypeOf :: (String,String) -> StateT TransInfo Identity TypeExpr  Deterministic 

Further infos:
  • partially defined

getConsTypeOf :: (String,String) -> StateT TransInfo Identity TypeExpr  Deterministic 

Further infos:
  • partially defined

applyTSubst :: [(Int,TypeExpr)] -> TypeExpr -> TypeExpr  Deterministic 

applyTSubst2Exp :: [(Int,TypeExpr)] -> Expr -> Expr  Deterministic 

allTVarsInFuncDecl :: FuncDecl -> [Int]  Deterministic 

allTVarsInTExp :: TypeExpr -> [Int]  Deterministic 

allTVarsInExp :: Expr -> [Int]  Deterministic 

allTVarsInTDecl :: TypeDecl -> [Int]  Deterministic