This library provides some useful operations to write programs that generate AbstractCurry programs in a more compact and readable way.
Version: September 2024
simpleCurryProg
:: String -> [String] -> [CTypeDecl] -> [CFuncDecl] -> [COpDecl] -> CurryProg
Constructs a simple CurryProg
without type classes and instances.
|
simpleInstanceDecl
:: (String,String) -> CTypeExpr -> [CFuncDecl] -> CInstanceDecl
Constructs a simple class instance for a given type and without a class constraint. |
simpleCCons
:: (String,String) -> CVisibility -> [CTypeExpr] -> CConsDecl
Constructs a simple constructor declaration without quantified type variables and type class constraints. |
applyTC
:: (String,String) -> [CTypeExpr] -> CTypeExpr
A type application of a qualified type constructor name to a list of argument types. |
(~>)
:: CTypeExpr -> CTypeExpr -> CTypeExpr
A function type. |
baseType
:: (String,String) -> CTypeExpr
A base type. |
listType
:: CTypeExpr -> CTypeExpr
Constructs a list type from an element type. |
tupleType
:: [CTypeExpr] -> CTypeExpr
Constructs a tuple type from list of component types. |
ioType
:: CTypeExpr -> CTypeExpr
Constructs an IO type from a type. |
maybeType
:: CTypeExpr -> CTypeExpr
Constructs a Maybe type from element type. |
stringType
:: CTypeExpr
The type expression of the String type. |
intType
:: CTypeExpr
The type expression of the Int type. |
floatType
:: CTypeExpr
The type expression of the Float type. |
boolType
:: CTypeExpr
The type expression of the Bool type. |
charType
:: CTypeExpr
The type expression of the Char type. |
unitType
:: CTypeExpr
The type expression of the unit type. |
dateType
:: CTypeExpr
The type expression of the Time.CalendarTime type. |
emptyClassType
:: CTypeExpr -> CQualTypeExpr
A qualified type with empty class constraints. |
singleClassType
:: (String,String) -> CTypeExpr -> CTypeExpr -> CQualTypeExpr
A qualified type with a single class constraint. |
singleCConstraint
:: (String,String) -> CTypeExpr -> ((String,String),[CTypeExpr])
A class constraint with a single parameter. |
cfunc
:: (String,String) -> Int -> CVisibility -> CQualTypeExpr -> [CRule] -> CFuncDecl
Constructs a function declaration from a given qualified function name, arity, visibility, type expression and list of defining rules. |
cmtfunc
:: String -> (String,String) -> Int -> CVisibility -> CQualTypeExpr -> [CRule] -> CFuncDecl
Constructs a function declaration from a given comment, qualified function name, arity, visibility, type expression and list of defining rules. |
stFunc
:: (String,String) -> Int -> CVisibility -> CTypeExpr -> [CRule] -> CFuncDecl
|
stCmtFunc
:: String -> (String,String) -> Int -> CVisibility -> CTypeExpr -> [CRule] -> CFuncDecl
|
simpleRule
:: [CPattern] -> CExpr -> CRule
Constructs a simple rule with a pattern list and an unconditional right-hand side. |
simpleRuleWithLocals
:: [CPattern] -> CExpr -> [CLocalDecl] -> CRule
Constructs a simple rule with a pattern list, an unconditional right-hand side, and local declarations. |
guardedRule
:: [CPattern] -> [(CExpr,CExpr)] -> [CLocalDecl] -> CRule
Constructs a rule with a possibly guarded right-hand side and local declarations. |
noGuard
:: CExpr -> (CExpr,CExpr)
Constructs a guarded expression with the trivial guard. |
simpleRhs
:: CExpr -> CRhs
Transforms an expression into a simple unconditional right-hand side. |
applyF
:: (String,String) -> [CExpr] -> CExpr
An application of a qualified function name to a list of arguments. |
applyE
:: CExpr -> [CExpr] -> CExpr
An application of an expression to a list of arguments. |
constF
:: (String,String) -> CExpr
A constant, i.e., an application without arguments. |
applyV
:: (Int,String) -> [CExpr] -> CExpr
An application of a variable to a list of arguments. |
applyJust
:: CExpr -> CExpr
|
applyMaybe
:: CExpr -> CExpr -> CExpr -> CExpr
|
tupleExpr
:: [CExpr] -> CExpr
Constructs a tuple expression from list of component expressions. |
ifThenElseExp
:: CExpr -> CExpr -> CExpr -> CExpr
Constructs an if-then-else expression. |
letExpr
:: [CLocalDecl] -> CExpr -> CExpr
Constructs a let declaration (with possibly empty local delcarations). |
simpleTyped
:: CExpr -> CTypeExpr -> CExpr
Constructs a typed expression from an expression and a simple type. |
doExpr
:: [CStatement] -> CExpr
Constructs a do expression. |
cBranch
:: CPattern -> CExpr -> (CPattern,CRhs)
Constructs from a pattern and an expression a branch for a case expression. |
tuplePattern
:: [CPattern] -> CPattern
Constructs a tuple pattern from list of component patterns. |
pVars
:: Int -> [CPattern]
Constructs, for given n, a list of n PVars starting from 0. |
pInt
:: Int -> CPattern
Converts an integer into an AbstractCurry expression. |
pFloat
:: Float -> CPattern
Converts a float into an AbstractCurry expression. |
pChar
:: Char -> CPattern
Converts a character into a pattern. |
pNil
:: CPattern
Constructs an empty list pattern. |
listPattern
:: [CPattern] -> CPattern
Constructs a list pattern from list of component patterns. |
stringPattern
:: String -> CPattern
Converts a string into a pattern representing this string. |
list2ac
:: [CExpr] -> CExpr
Converts a list of AbstractCurry expressions into an AbstractCurry representation of this list. |
cInt
:: Int -> CExpr
Converts an integer into an AbstractCurry expression. |
cFloat
:: Float -> CExpr
Converts a float into an AbstractCurry expression. |
cChar
:: Char -> CExpr
Converts a character into an AbstractCurry expression. |
string2ac
:: String -> CExpr
Converts a string into an AbstractCurry represention of this string. |
toVar
:: Int -> CExpr
Converts an index i into a variable named xi. |
cvar
:: String -> CExpr
Converts a string into a variable with index 1. |
cpvar
:: String -> CPattern
Converts a string into a pattern variable with index 1. |
ctvar
:: String -> CTypeExpr
Converts a string into a type variable with index 1. |
Constructs a simple
|
Constructs a simple class instance for a given type and without a class constraint. Thus, the instance definition has the form instance c ty where { ...;fundecl;... }
|
Constructs a simple constructor declaration without quantified type variables and type class constraints.
|
A type application of a qualified type constructor name to a list of argument types. |
A function type.
|
A base type.
|
Constructs a list type from an element type.
|
Constructs an IO type from a type.
|
Constructs a Maybe type from element type.
|
The type expression of the String type.
|
The type expression of the Int type.
|
The type expression of the Float type.
|
The type expression of the Bool type.
|
The type expression of the Char type.
|
The type expression of the unit type.
|
The type expression of the Time.CalendarTime type.
|
A qualified type with empty class constraints.
|
A qualified type with a single class constraint. The arguments are the class name, the actual type parameter of the class, and the type expression constrained by the class constraint.
|
A class constraint with a single parameter. The arguments are the class name and the type parameter of the class.
|
Constructs a function declaration from a given qualified function name, arity, visibility, type expression and list of defining rules.
|
Constructs a function declaration from a given comment, qualified function name, arity, visibility, type expression and list of defining rules.
|
|
|
Constructs a simple rule with a pattern list and an unconditional right-hand side.
|
Constructs a simple rule with a pattern list, an unconditional right-hand side, and local declarations.
|
Constructs a rule with a possibly guarded right-hand side
and local declarations.
A simple right-hand side is constructed if there is only one
|
Constructs a guarded expression with the trivial guard.
|
Transforms an expression into a simple unconditional right-hand side.
|
An application of a qualified function name to a list of arguments. |
|
Constructs an if-then-else expression. |
Constructs a let declaration (with possibly empty local delcarations). |
Constructs a typed expression from an expression and a simple type.
|
Constructs a do expression. If the list of statements in the do expression contains a single expression, the do expression is transformed into a simple expression. |
Constructs from a pattern and an expression a branch for a case expression.
|
Constructs a tuple pattern from list of component patterns. |
Converts an integer into an AbstractCurry expression.
|
Converts a float into an AbstractCurry expression.
|
Converts a character into a pattern.
|
Constructs an empty list pattern.
|
Constructs a list pattern from list of component patterns.
|
Converts a string into a pattern representing this string. |
Converts a list of AbstractCurry expressions into an AbstractCurry representation of this list. |
Converts an integer into an AbstractCurry expression.
|
Converts a float into an AbstractCurry expression.
|
Converts a character into an AbstractCurry expression.
|
Converts a string into an AbstractCurry represention of this string.
|
Converts a string into a variable with index 1.
|
Converts a string into a pattern variable with index 1.
|