Module FlatCurryGoodies

This module provides some additional goodies for annotated FlatCurry.

Author: Jan Tikovsky

Version: October 2017

Summary of exported operations:

extendAnn :: a -> (a,Maybe Int,Bool)   
Extend given annotation to default IDAnn annotation
tyAnn :: (TypeExpr,Maybe Int,Bool) -> TypeExpr   
Select type annotation
cidAnn :: (TypeExpr,Maybe Int,Bool) -> Int   
Select case identifier annotation
litAnn :: (TypeExpr,Maybe Int,Bool) -> Bool   
Select literal annotation
mkFunType :: [TypeExpr] -> TypeExpr -> TypeExpr   
Generate a functional FlatCurry type expression from a list of argument types and a result type
hasName :: (String,String) -> AFuncDecl a -> Bool   
prel :: String -> (String,String)   
Qualification of Prelude functions
qualPrel :: (String,a) -> ((String,String),a)   
Qualify first component of a tuple with "Prelude"
isDict :: (String,String) -> Bool   
Check whether the qualified name represents a dictionary
failedExpr :: (TypeExpr,Maybe Int,Bool) -> AExpr (TypeExpr,Maybe Int,Bool)   
Annotated FlatCurry expression representing failed
mkOr :: AExpr (TypeExpr,Maybe Int,Bool) -> AExpr (TypeExpr,Maybe Int,Bool) -> AExpr (TypeExpr,Maybe Int,Bool)   
smart constructor for a nondeterministic choice in FlatCurry
boolType :: TypeExpr   
Representation of some basic types in FlatCurry
intType :: TypeExpr   
charType :: TypeExpr   
floatType :: TypeExpr   
listType :: TypeExpr -> TypeExpr   
unitType :: TypeExpr   
Extended annotation for ()
boolAnn :: (TypeExpr,Maybe Int,Bool)   
Representation of extended annotations Extended annotation for Bool
intAnn :: (TypeExpr,Maybe Int,Bool)   
Extended annotation for Int
charAnn :: (TypeExpr,Maybe Int,Bool)   
Extended annotation for Char
floatAnn :: (TypeExpr,Maybe Int,Bool)   
Extended annotation for Float
listAnn :: TypeExpr -> (TypeExpr,Maybe Int,Bool)   
Extended annotation for the list type constructor
tplAnn :: [TypeExpr] -> (TypeExpr,Maybe Int,Bool)   
Extended annotation for the tuple type constructor
condAnn :: TypeExpr -> (TypeExpr,Maybe Int,Bool)   
Extended annotations of Prelude functions Extended annotation for type Bool -> a -> a
ampAnn :: (TypeExpr,Maybe Int,Bool)   
Extended annotation for type Bool -> Bool -> Bool
unifyAnn :: (TypeExpr,Maybe Int,Bool) -> (TypeExpr,Maybe Int,Bool)   
Extended annotation for type a -> a -> Bool
trueExpr :: AExpr (TypeExpr,Maybe Int,Bool)   
FlatCurry expressions Annotated FlatCurry expression representing True
falseExpr :: AExpr (TypeExpr,Maybe Int,Bool)   
Annotated FlatCurry expression representing False
nil :: AExpr (TypeExpr,Maybe Int,Bool)   
Annotated FlatCurry expression representing []
cons :: TypeExpr -> [AExpr (TypeExpr,Maybe Int,Bool)] -> AExpr (TypeExpr,Maybe Int,Bool)   
Annotated FlatCurry expression representing :
tpl :: [TypeExpr] -> [AExpr (TypeExpr,Maybe Int,Bool)] -> AExpr (TypeExpr,Maybe Int,Bool)   
FlatCurry expression representing (,)
isBoolType :: TypeExpr -> Bool   
Check if the given FlatCurry type is a boolean type
isOtherwise :: AExpr a -> Bool   
Check if the given FlatCurry expression is otherwise
hasBoolType :: AExpr (TypeExpr,Maybe Int,Bool) -> Bool   
isConj :: AExpr a -> Bool   
Check if the given FlatCurry expression is a boolean conjunction
isDisj :: AExpr a -> Bool   
Check if the given FlatCurry expression is a boolean disjunction
truePat :: APattern (TypeExpr,Maybe Int,Bool)   
FlatCurry pattern FlatCurry True pattern
falsePat :: APattern (TypeExpr,Maybe Int,Bool)   
FlatCurry False pattern
resArgTypes :: TypeExpr -> [TypeExpr]   
Get the result type followed by the argument types in given order
patVars :: APattern a -> [Int]   
Select the pattern variables of a given pattern
getVarIdx :: AExpr a -> [Int]   
Get the variable index of a FlatCurry expression
getTyVars :: TypeExpr -> [Int]   
Get all type variables of a given FlatCurry type expression
eqPattern :: APattern a -> APattern a -> Bool   
Check if two pattern are equal
findFunc :: (String,String) -> [AFuncDecl a] -> Maybe (AFuncDecl a)   
Find the function declaration for given qualified name
findBranch :: APattern a -> [ABranchExpr a] -> Maybe (Int,[Int],AExpr a)   
Find the matching branch for a given pattern
addPartCallArg :: a -> CombType -> ((String,String),a) -> [AExpr a] -> AExpr a -> AExpr a   
Add an argument to a partial call
isPartCall :: CombType -> Bool   
Check if given combination type is a partial call
combine :: (String,String) -> (String,String) -> AExpr (TypeExpr,Maybe Int,Bool) -> [AExpr (TypeExpr,Maybe Int,Bool)] -> [AExpr (TypeExpr,Maybe Int,Bool)] -> AExpr (TypeExpr,Maybe Int,Bool)   
Combine given expressions lists with =:= or =:<= and resulting unifications with &
getMainBody :: AProg a -> Maybe (AExpr a)   
Get the rhs expression of the main function of the given FlatCurry program

Exported datatypes:


IDAnn

Extended annotations for concolic testing Extended FlatCurry annotation for concolic testing providing

  • case identifiers and
  • literal flags

Type synonym: IDAnn a = (a,Maybe VarIndex,Bool)


TypeAnn

Concolic testing annotation with type information

Type synonym: TypeAnn = IDAnn TypeExpr


Exported operations:

extendAnn :: a -> (a,Maybe Int,Bool)   

Extend given annotation to default IDAnn annotation

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

tyAnn :: (TypeExpr,Maybe Int,Bool) -> TypeExpr   

Select type annotation

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

cidAnn :: (TypeExpr,Maybe Int,Bool) -> Int   

Select case identifier annotation

litAnn :: (TypeExpr,Maybe Int,Bool) -> Bool   

Select literal annotation

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

mkFunType :: [TypeExpr] -> TypeExpr -> TypeExpr   

Generate a functional FlatCurry type expression from a list of argument types and a result type

hasName :: (String,String) -> AFuncDecl a -> Bool   

prel :: String -> (String,String)   

Qualification of Prelude functions

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

qualPrel :: (String,a) -> ((String,String),a)   

Qualify first component of a tuple with "Prelude"

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

isDict :: (String,String) -> Bool   

Check whether the qualified name represents a dictionary

failedExpr :: (TypeExpr,Maybe Int,Bool) -> AExpr (TypeExpr,Maybe Int,Bool)   

Annotated FlatCurry expression representing failed

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

mkOr :: AExpr (TypeExpr,Maybe Int,Bool) -> AExpr (TypeExpr,Maybe Int,Bool) -> AExpr (TypeExpr,Maybe Int,Bool)   

smart constructor for a nondeterministic choice in FlatCurry

boolType :: TypeExpr   

Representation of some basic types in FlatCurry

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

intType :: TypeExpr   

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

charType :: TypeExpr   

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

floatType :: TypeExpr   

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

listType :: TypeExpr -> TypeExpr   

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

unitType :: TypeExpr   

Extended annotation for ()

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

boolAnn :: (TypeExpr,Maybe Int,Bool)   

Representation of extended annotations Extended annotation for Bool

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

intAnn :: (TypeExpr,Maybe Int,Bool)   

Extended annotation for Int

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

charAnn :: (TypeExpr,Maybe Int,Bool)   

Extended annotation for Char

floatAnn :: (TypeExpr,Maybe Int,Bool)   

Extended annotation for Float

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

listAnn :: TypeExpr -> (TypeExpr,Maybe Int,Bool)   

Extended annotation for the list type constructor

tplAnn :: [TypeExpr] -> (TypeExpr,Maybe Int,Bool)   

Extended annotation for the tuple type constructor

condAnn :: TypeExpr -> (TypeExpr,Maybe Int,Bool)   

Extended annotations of Prelude functions Extended annotation for type Bool -> a -> a

ampAnn :: (TypeExpr,Maybe Int,Bool)   

Extended annotation for type Bool -> Bool -> Bool

unifyAnn :: (TypeExpr,Maybe Int,Bool) -> (TypeExpr,Maybe Int,Bool)   

Extended annotation for type a -> a -> Bool

trueExpr :: AExpr (TypeExpr,Maybe Int,Bool)   

FlatCurry expressions Annotated FlatCurry expression representing True

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

falseExpr :: AExpr (TypeExpr,Maybe Int,Bool)   

Annotated FlatCurry expression representing False

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

nil :: AExpr (TypeExpr,Maybe Int,Bool)   

Annotated FlatCurry expression representing []

cons :: TypeExpr -> [AExpr (TypeExpr,Maybe Int,Bool)] -> AExpr (TypeExpr,Maybe Int,Bool)   

Annotated FlatCurry expression representing :

tpl :: [TypeExpr] -> [AExpr (TypeExpr,Maybe Int,Bool)] -> AExpr (TypeExpr,Maybe Int,Bool)   

FlatCurry expression representing (,)

isBoolType :: TypeExpr -> Bool   

Check if the given FlatCurry type is a boolean type

isOtherwise :: AExpr a -> Bool   

Check if the given FlatCurry expression is otherwise

hasBoolType :: AExpr (TypeExpr,Maybe Int,Bool) -> Bool   

isConj :: AExpr a -> Bool   

Check if the given FlatCurry expression is a boolean conjunction

isDisj :: AExpr a -> Bool   

Check if the given FlatCurry expression is a boolean disjunction

truePat :: APattern (TypeExpr,Maybe Int,Bool)   

FlatCurry pattern FlatCurry True pattern

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

falsePat :: APattern (TypeExpr,Maybe Int,Bool)   

FlatCurry False pattern

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

resArgTypes :: TypeExpr -> [TypeExpr]   

Get the result type followed by the argument types in given order

patVars :: APattern a -> [Int]   

Select the pattern variables of a given pattern

getVarIdx :: AExpr a -> [Int]   

Get the variable index of a FlatCurry expression

getTyVars :: TypeExpr -> [Int]   

Get all type variables of a given FlatCurry type expression

eqPattern :: APattern a -> APattern a -> Bool   

Check if two pattern are equal

findFunc :: (String,String) -> [AFuncDecl a] -> Maybe (AFuncDecl a)   

Find the function declaration for given qualified name

findBranch :: APattern a -> [ABranchExpr a] -> Maybe (Int,[Int],AExpr a)   

Find the matching branch for a given pattern

addPartCallArg :: a -> CombType -> ((String,String),a) -> [AExpr a] -> AExpr a -> AExpr a   

Add an argument to a partial call

isPartCall :: CombType -> Bool   

Check if given combination type is a partial call

combine :: (String,String) -> (String,String) -> AExpr (TypeExpr,Maybe Int,Bool) -> [AExpr (TypeExpr,Maybe Int,Bool)] -> [AExpr (TypeExpr,Maybe Int,Bool)] -> AExpr (TypeExpr,Maybe Int,Bool)   

Combine given expressions lists with =:= or =:<= and resulting unifications with &

getMainBody :: AProg a -> Maybe (AExpr a)   

Get the rhs expression of the main function of the given FlatCurry program