This module contains the definition and operations for a state containing information about already loaded FlatCurry programs. The state is used during the execution of the tool in order to avoid multiple loading of FlatCurry programs.
Author: Michael Hanus
Version: March 2024
readTransFlatCurry
:: String -> IO Prog
Read and transform a module in FlatCurry format. |
transformChoiceInProg
:: Prog -> Prog
Replace all occurrences of Prelude.?
in a FlatCurry program by
Or
expressions.
|
removeTopForallType
:: Prog -> Prog
Remove the top-level ForallType
constructors from all function signatures.
|
completeBranchesInFunc
:: [((String,String),(Int,ConsType,[((String,String),Int)]))] -> Bool -> FuncDecl -> FuncDecl
Complete all partial case branches occurring in the body of a function by adding Prelude.failed
branches.
|
consInfoOfTypeDecls
:: [TypeDecl] -> [((String,String),(Int,ConsType,[((String,String),Int)]))]
Transforms a list of type declarations into constructor information. |
consInfoOfTypeDecl
:: TypeDecl -> [((String,String),(Int,ConsType,[((String,String),Int)]))]
Transforms a type declaration into constructor information. |
infoOfCons
:: [((String,String),(Int,ConsType,[((String,String),Int)]))] -> (String,String) -> (Int,ConsType,[((String,String),Int)])
Gets the the information about a given constructor name. |
arityOfCons
:: [((String,String),(Int,ConsType,[((String,String),Int)]))] -> (String,String) -> Int
Gets the arity of a constructor from information about all constructors. |
siblingsOfCons
:: [((String,String),(Int,ConsType,[((String,String),Int)]))] -> (String,String) -> [((String,String),Int)]
Gets the siblings of a constructor w.r.t. |
isCompleteConstructorList
:: [((String,String),(Int,ConsType,[((String,String),Int)]))] -> [(String,String)] -> Bool
Is a non-empty list of constructors complete, i.e., does it contain all the constructors of a type? The first argument contains information about all constructors in a program. |
emptyProgInfo
:: ProgInfo
|
prog2ModInfo
:: Prog -> ModInfo
|
addModInfoFor
:: IORef ProgInfo -> String -> IO ()
Read a module and adds the info for it. |
hasModInfoFor
:: IORef ProgInfo -> String -> IO Bool
Does the info for a module with a given name already exists? |
getModInfoFor
:: IORef ProgInfo -> String -> IO ModInfo
Gets the info for a module with a given name. |
getFlatProgFor
:: IORef ProgInfo -> String -> IO Prog
Gets the FlatCurry program for a module with a given name. |
getTypeDeclOf
:: IORef ProgInfo -> (String,String) -> IO TypeDecl
Gets the type declaration for a given type constructor. |
The information about a constructor consists of the arity, type, and the siblings of the constructor. The siblings are represented as pairs of the qualified constructor name and their arity.
Type synonym: ConsInfo = (Int,ConsType,[(QName,Int)])
The type of a constructor consists of the argument types, the type constructor and the type parameters of the constructor.
Constructors:
The global program information is a mapping from module names
to infos about the module. The main program keeps an IORef
to this
structure.
Constructors:
Constructors:
Read and transform a module in FlatCurry format.
In particular, occurrences of |
Replace all occurrences of |
Remove the top-level |
Complete all partial case branches occurring in the body of a function
by adding |
Transforms a list of type declarations into constructor information. |
Transforms a type declaration into constructor information. |
Gets the the information about a given constructor name. |
Gets the arity of a constructor from information about all constructors.
|
Gets the siblings of a constructor w.r.t. constructor information. |
Is a non-empty list of constructors complete, i.e., does it contain all the constructors of a type? The first argument contains information about all constructors in a program.
|
|
|
Read a module and adds the info for it. |
Does the info for a module with a given name already exists? |
Gets the info for a module with a given name. If it is not already stored, read the module and store it. |
Gets the FlatCurry program for a module with a given name. |
Gets the type declaration for a given type constructor. |