This library provides transformation and update operations
on AbstractCurry programs.
Since the transformations are defined recursively on structured types,
they are useful to construct specific transformations on AbstractCurry
programs.
In particular, this library contains the transformation
renameCurryModule
to rename an AbstractCurry module.
Author: Michael Hanus
Version: August 2024
trCProg
:: (String -> [String] -> Maybe CDefaultDecl -> [CClassDecl] -> [CInstanceDecl] -> [CTypeDecl] -> [CFuncDecl] -> [COpDecl] -> a) -> CurryProg -> a
Transforms an AbstractCurry program. |
updCProg
:: (String -> String) -> ([String] -> [String]) -> (Maybe CDefaultDecl -> Maybe CDefaultDecl) -> ([CClassDecl] -> [CClassDecl]) -> ([CInstanceDecl] -> [CInstanceDecl]) -> ([CTypeDecl] -> [CTypeDecl]) -> ([CFuncDecl] -> [CFuncDecl]) -> ([COpDecl] -> [COpDecl]) -> CurryProg -> CurryProg
Updates an AbstractCurry program. |
updCProgName
:: (String -> String) -> CurryProg -> CurryProg
Updates the name of a Curry program. |
trCDefaultDecl
:: ([CTypeExpr] -> a) -> CDefaultDecl -> a
Transforms a default declaration. |
updCDefaultDecl
:: ([CTypeExpr] -> [CTypeExpr]) -> CDefaultDecl -> CDefaultDecl
Updates a default declaration. |
trCContext
:: ([((String,String),[CTypeExpr])] -> a) -> CContext -> a
Transforms a class context. |
updCContext
:: ([((String,String),[CTypeExpr])] -> [((String,String),[CTypeExpr])]) -> CContext -> CContext
Updates a class context. |
trCClassDecl
:: ((String,String) -> CVisibility -> CContext -> [(Int,String)] -> [([(Int,String)],[(Int,String)])] -> [CFuncDecl] -> a) -> CClassDecl -> a
Transforms a class declaration. |
updCClassDecl
:: ((String,String) -> (String,String)) -> (CVisibility -> CVisibility) -> (CContext -> CContext) -> ([(Int,String)] -> [(Int,String)]) -> ([([(Int,String)],[(Int,String)])] -> [([(Int,String)],[(Int,String)])]) -> ([CFuncDecl] -> [CFuncDecl]) -> CClassDecl -> CClassDecl
Updates a class declaration. |
trCInstanceDecl
:: ((String,String) -> CContext -> [CTypeExpr] -> [CFuncDecl] -> a) -> CInstanceDecl -> a
Transforms a class declaration. |
updCInstanceDecl
:: ((String,String) -> (String,String)) -> (CContext -> CContext) -> ([CTypeExpr] -> [CTypeExpr]) -> ([CFuncDecl] -> [CFuncDecl]) -> CInstanceDecl -> CInstanceDecl
Updates an AbstractCurry program. |
trCTypeDecl
:: ((String,String) -> CVisibility -> [(Int,String)] -> [CConsDecl] -> [(String,String)] -> a) -> ((String,String) -> CVisibility -> [(Int,String)] -> CTypeExpr -> a) -> ((String,String) -> CVisibility -> [(Int,String)] -> CConsDecl -> [(String,String)] -> a) -> CTypeDecl -> a
Transforms a type declaration. |
updCTypeDecl
:: ((String,String) -> (String,String)) -> (CVisibility -> CVisibility) -> ([(Int,String)] -> [(Int,String)]) -> ([CConsDecl] -> [CConsDecl]) -> (CTypeExpr -> CTypeExpr) -> (CConsDecl -> CConsDecl) -> ([(String,String)] -> [(String,String)]) -> CTypeDecl -> CTypeDecl
update type declaration |
updCTypeDeclName
:: ((String,String) -> (String,String)) -> CTypeDecl -> CTypeDecl
Updates the name of a type declaration. |
trCConsDecl
:: ((String,String) -> CVisibility -> [CTypeExpr] -> a) -> ((String,String) -> CVisibility -> [CFieldDecl] -> a) -> CConsDecl -> a
Transforms a constructor declaration. |
updCConsDecl
:: ((String,String) -> (String,String)) -> (CVisibility -> CVisibility) -> ([CTypeExpr] -> [CTypeExpr]) -> ([CFieldDecl] -> [CFieldDecl]) -> CConsDecl -> CConsDecl
Updates a constructor declaration. |
updCConsDeclName
:: ((String,String) -> (String,String)) -> CConsDecl -> CConsDecl
Updates the name of a constructor declaration. |
trCFieldDecl
:: ((String,String) -> CVisibility -> CTypeExpr -> a) -> CFieldDecl -> a
Transforms a constructor declaration. |
updCFieldDecl
:: ((String,String) -> (String,String)) -> (CVisibility -> CVisibility) -> (CTypeExpr -> CTypeExpr) -> CFieldDecl -> CFieldDecl
update constructor declaration |
updCFieldDeclName
:: ((String,String) -> (String,String)) -> CFieldDecl -> CFieldDecl
Updates the name of a constructor declaration. |
trCQualTypeExpr
:: (CContext -> CTypeExpr -> a) -> CQualTypeExpr -> a
Transforms a default declaration. |
updCQualTypeExpr
:: (CContext -> CContext) -> (CTypeExpr -> CTypeExpr) -> CQualTypeExpr -> CQualTypeExpr
Updates a default declaration. |
trCTypeExpr
:: ((Int,String) -> a) -> ((String,String) -> a) -> (a -> a -> a) -> (a -> a -> a) -> CTypeExpr -> a
Transforms a type expression. |
updTConsApp
:: ((String,String) -> CTypeExpr) -> CTypeExpr -> CTypeExpr
Updates all type constructors in a type expression. |
trCOpDecl
:: ((String,String) -> CFixity -> Int -> a) -> COpDecl -> a
Transforms an operator declaration. |
updCOpDecl
:: ((String,String) -> (String,String)) -> (CFixity -> CFixity) -> (Int -> Int) -> COpDecl -> COpDecl
Updates an operator declaration. |
updCOpName
:: ((String,String) -> (String,String)) -> COpDecl -> COpDecl
Updates the name of an operator declaration. |
trCFuncDecl
:: (String -> (String,String) -> Int -> CVisibility -> CQualTypeExpr -> [CRule] -> a) -> CFuncDecl -> a
Transforms a function declaration |
updCFuncDecl
:: (String -> String) -> ((String,String) -> (String,String)) -> (Int -> Int) -> (CVisibility -> CVisibility) -> (CQualTypeExpr -> CQualTypeExpr) -> ([CRule] -> [CRule]) -> CFuncDecl -> CFuncDecl
Updates a function declaration. |
trCRule
:: ([CPattern] -> CRhs -> a) -> CRule -> a
Transform a rule. |
updCRule
:: ([CPattern] -> [CPattern]) -> (CRhs -> CRhs) -> CRule -> CRule
Update a rule. |
trCRhs
:: (CExpr -> [CLocalDecl] -> a) -> ([(CExpr,CExpr)] -> [CLocalDecl] -> a) -> CRhs -> a
Transforms a right-hand side (of a rule or case expression). |
updCRhs
:: (CExpr -> CExpr) -> ([(CExpr,CExpr)] -> [(CExpr,CExpr)]) -> ([CLocalDecl] -> [CLocalDecl]) -> CRhs -> CRhs
Updates right-hand side. |
trCLocalDecl
:: (CFuncDecl -> a) -> (CPattern -> CRhs -> a) -> ([(Int,String)] -> a) -> CLocalDecl -> a
Transforms a local declaration. |
updCLocalDecl
:: (CFuncDecl -> CFuncDecl) -> (CPattern -> CPattern) -> (CRhs -> CRhs) -> ([(Int,String)] -> [(Int,String)]) -> CLocalDecl -> CLocalDecl
Updates a local declaration. |
trCPattern
:: ((Int,String) -> a) -> (CLiteral -> a) -> ((String,String) -> [a] -> a) -> ((Int,String) -> a -> a) -> ((String,String) -> [a] -> a) -> ((String,String) -> [((String,String),a)] -> a) -> CPattern -> a
Transforms a pattern. |
updCPattern
:: ((Int,String) -> (Int,String)) -> (CLiteral -> CLiteral) -> ((String,String) -> (String,String)) -> CPattern -> CPattern
Updates a pattern. |
trExpr
:: ((Int,String) -> a) -> (CLiteral -> a) -> ((String,String) -> a) -> (a -> a -> a) -> ([CPattern] -> a -> a) -> ([CLocalDecl] -> a -> a) -> ([CStatement] -> a) -> (a -> [CStatement] -> a) -> (CCaseType -> a -> [(CPattern,CRhs)] -> a) -> (a -> CQualTypeExpr -> a) -> ((String,String) -> [((String,String),a)] -> a) -> (a -> [((String,String),a)] -> a) -> CExpr -> a
Transforms an expression. |
trCStatement
:: (CExpr -> a) -> (CPattern -> CExpr -> a) -> ([CLocalDecl] -> a) -> CStatement -> a
Transforms a statement (occuring in do expressions or list comprehensions). |
updCStatement
:: (CExpr -> CExpr) -> (CPattern -> CPattern) -> (CLocalDecl -> CLocalDecl) -> CStatement -> CStatement
Updates a statement (occuring in do expressions or list comprehensions). |
renameCurryModule
:: String -> CurryProg -> CurryProg
Renames a Curry module, i.e., updates the module name and all qualified names in a program. |
updQNamesInCProg
:: ((String,String) -> (String,String)) -> CurryProg -> CurryProg
Updates all qualified names in a Curry program. |
updQNamesInCDefaultDecl
:: ((String,String) -> (String,String)) -> Maybe CDefaultDecl -> Maybe CDefaultDecl
Updates all qualified names in a default declaration. |
updQNamesInCClassDecl
:: ((String,String) -> (String,String)) -> CClassDecl -> CClassDecl
Updates all qualified names in a class declaration. |
updQNamesInCInstanceDecl
:: ((String,String) -> (String,String)) -> CInstanceDecl -> CInstanceDecl
Updates all qualified names in an instance declaration. |
updQNamesInCTypeDecl
:: ((String,String) -> (String,String)) -> CTypeDecl -> CTypeDecl
Updates all qualified names in a type declaration. |
updQNamesInCConsDecl
:: ((String,String) -> (String,String)) -> CConsDecl -> CConsDecl
Updates all qualified names in a constructor declaration. |
updQNamesInCContext
:: ((String,String) -> (String,String)) -> CContext -> CContext
Updates all qualified names in a constructor declaration. |
updQNamesInCFieldDecl
:: ((String,String) -> (String,String)) -> CFieldDecl -> CFieldDecl
Updates all qualified names in a record field declaration. |
updQNamesInCQualTypeExpr
:: ((String,String) -> (String,String)) -> CQualTypeExpr -> CQualTypeExpr
Updates all qualified names in a type expression. |
updQNamesInCTypeExpr
:: ((String,String) -> (String,String)) -> CTypeExpr -> CTypeExpr
Updates all qualified names in a type expression. |
updQNamesInCFuncDecl
:: ((String,String) -> (String,String)) -> CFuncDecl -> CFuncDecl
Updates all qualified names in a function declaration. |
updQNamesInCRule
:: ((String,String) -> (String,String)) -> CRule -> CRule
Updates all qualified names in a function declaration. |
updQNamesInCRhs
:: ((String,String) -> (String,String)) -> CRhs -> CRhs
Updates all qualified names in a function declaration. |
updQNamesInCLocalDecl
:: ((String,String) -> (String,String)) -> CLocalDecl -> CLocalDecl
Updates all qualified names in a function declaration. |
updQNamesInCPattern
:: ((String,String) -> (String,String)) -> CPattern -> CPattern
Updates all qualified names in a function declaration. |
updQNamesInCStatement
:: ((String,String) -> (String,String)) -> CStatement -> CStatement
Updates all qualified names in a statement. |
updQNamesInCExpr
:: ((String,String) -> (String,String)) -> CExpr -> CExpr
|
typesOfCurryProg
:: CurryProg -> [(String,String)]
Extracts all type names occurring in a program. |
typesOfCClassDecl
:: CClassDecl -> [(String,String)]
Extracts all type names occurring in a class declaration. |
typesOfCInstanceDecl
:: CInstanceDecl -> [(String,String)]
Extracts all type names occurring in a class declaration. |
typesOfCTypeDecl
:: CTypeDecl -> [(String,String)]
Extracts all type names occurring in a type declaration. |
typesOfConsDecl
:: CConsDecl -> [(String,String)]
|
typesOfFieldDecl
:: CFieldDecl -> [(String,String)]
|
typesOfContext
:: CContext -> [(String,String)]
|
typesOfTypeExpr
:: CTypeExpr -> [(String,String)]
|
typesOfQualTypeExpr
:: CQualTypeExpr -> [(String,String)]
|
typesOfCFuncDecl
:: CFuncDecl -> [(String,String)]
|
unionMap
:: Eq a => (b -> [a]) -> [b] -> [a]
|
funcsOfCurryProg
:: CurryProg -> [(String,String)]
Extracts all function (and constructor) names occurring in a program. |
funcsOfCClassDecl
:: CClassDecl -> [(String,String)]
|
funcsOfCInstanceDecl
:: CInstanceDecl -> [(String,String)]
|
funcsOfCTypeDecl
:: CTypeDecl -> [(String,String)]
|
funcsOfConsDecl
:: CConsDecl -> [(String,String)]
|
funcsOfFieldDecl
:: CFieldDecl -> [(String,String)]
|
funcsOfCFuncDecl
:: CFuncDecl -> [(String,String)]
Extracts all function (and constructor) names occurring in a function declaration. |
funcsOfCRule
:: CRule -> [(String,String)]
|
funcsOfCRhs
:: CRhs -> [(String,String)]
|
funcsOfLDecl
:: CLocalDecl -> [(String,String)]
|
funcsOfExpr
:: CExpr -> [(String,String)]
|
funcsOfStat
:: CStatement -> [(String,String)]
|
This type synonym is useful to denote the type of an update, where the first argument is the type of values which are updated by the local update (which acts on types described by the second argument).
Type synonym: Update a b = (b -> b) -> a -> a
Transforms an AbstractCurry program. |
Updates an AbstractCurry program. |
Updates the name of a Curry program. |
Transforms a default declaration. |
Updates a default declaration. |
Transforms a class context. |
Updates a class context. |
Transforms a class declaration. |
Updates a class declaration. |
Transforms a class declaration. |
Updates an AbstractCurry program. |
Transforms a type declaration. |
update type declaration |
Updates the name of a type declaration. |
Transforms a constructor declaration. |
Updates a constructor declaration. |
Updates the name of a constructor declaration. |
Transforms a constructor declaration. |
update constructor declaration |
Updates the name of a constructor declaration. |
Transforms a default declaration. |
Updates a default declaration. |
Transforms a type expression. |
Updates all type constructors in a type expression. |
Transforms an operator declaration. |
Updates an operator declaration. |
Updates the name of an operator declaration. |
Transforms a function declaration |
Updates a function declaration. |
Transforms a right-hand side (of a rule or case expression). |
Updates right-hand side. |
Transforms a local declaration. |
Updates a local declaration. |
Transforms a pattern. |
Updates a pattern. |
Transforms an expression. |
Transforms a statement (occuring in do expressions or list comprehensions). |
Updates a statement (occuring in do expressions or list comprehensions). |
Renames a Curry module, i.e., updates the module name and all qualified names in a program. |
Updates all qualified names in a Curry program. |
Updates all qualified names in a default declaration. |
Updates all qualified names in a class declaration. |
Updates all qualified names in an instance declaration. |
Updates all qualified names in a type declaration. |
Updates all qualified names in a constructor declaration. |
Updates all qualified names in a constructor declaration. |
Updates all qualified names in a record field declaration. |
Updates all qualified names in a type expression. |
Updates all qualified names in a type expression. |
Updates all qualified names in a function declaration. |
Updates all qualified names in a function declaration. |
Updates all qualified names in a function declaration. |
Updates all qualified names in a function declaration. |
Updates all qualified names in a function declaration. |
Updates all qualified names in a statement. |
|
Extracts all type names occurring in a program. |
Extracts all type names occurring in a class declaration. Class names are ignored. |
Extracts all type names occurring in a class declaration. Class names are ignored. |
Extracts all type names occurring in a type declaration. Class names are ignored. |
|
|
|
|
|
|
|
Extracts all function (and constructor) names occurring in a program. |
|
|
|
|
|
Extracts all function (and constructor) names occurring in a function declaration. |
|
|
|
|
|