Module AbstractCurry.Build

This library provides some useful operations to write programs that generate AbstractCurry programs in a more compact and readable way.

Version: June 2023

Summary of exported operations:

simpleCurryProg :: String -> [String] -> [CTypeDecl] -> [CFuncDecl] -> [COpDecl] -> CurryProg  Deterministic 
Constructs a simple CurryProg without type classes and instances.
simpleCCons :: (String,String) -> CVisibility -> [CTypeExpr] -> CConsDecl  Deterministic 
Constructs a simple constructor declaration without quantified type variables and type class constraints.
applyTC :: (String,String) -> [CTypeExpr] -> CTypeExpr  Deterministic 
A type application of a qualified type constructor name to a list of argument types.
(~>) :: CTypeExpr -> CTypeExpr -> CTypeExpr  Deterministic 
A function type.
baseType :: (String,String) -> CTypeExpr  Deterministic 
A base type.
listType :: CTypeExpr -> CTypeExpr  Deterministic 
Constructs a list type from an element type.
tupleType :: [CTypeExpr] -> CTypeExpr  Deterministic 
Constructs a tuple type from list of component types.
ioType :: CTypeExpr -> CTypeExpr  Deterministic 
Constructs an IO type from a type.
maybeType :: CTypeExpr -> CTypeExpr  Deterministic 
Constructs a Maybe type from element type.
stringType :: CTypeExpr  Deterministic 
The type expression of the String type.
intType :: CTypeExpr  Deterministic 
The type expression of the Int type.
floatType :: CTypeExpr  Deterministic 
The type expression of the Float type.
boolType :: CTypeExpr  Deterministic 
The type expression of the Bool type.
charType :: CTypeExpr  Deterministic 
The type expression of the Char type.
unitType :: CTypeExpr  Deterministic 
The type expression of the unit type.
dateType :: CTypeExpr  Deterministic 
The type expression of the Time.CalendarTime type.
emptyClassType :: CTypeExpr -> CQualTypeExpr  Deterministic 
A qualified type with empty class constraints.
cfunc :: (String,String) -> Int -> CVisibility -> CQualTypeExpr -> [CRule] -> CFuncDecl  Deterministic 
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  Deterministic 
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  Deterministic 
stCmtFunc :: String -> (String,String) -> Int -> CVisibility -> CTypeExpr -> [CRule] -> CFuncDecl  Deterministic 
simpleRule :: [CPattern] -> CExpr -> CRule  Deterministic 
Constructs a simple rule with a pattern list and an unconditional right-hand side.
simpleRuleWithLocals :: [CPattern] -> CExpr -> [CLocalDecl] -> CRule  Deterministic 
Constructs a simple rule with a pattern list, an unconditional right-hand side, and local declarations.
guardedRule :: [CPattern] -> [(CExpr,CExpr)] -> [CLocalDecl] -> CRule  Deterministic 
Constructs a rule with a possibly guarded right-hand side and local declarations.
noGuard :: CExpr -> (CExpr,CExpr)  Deterministic 
Constructs a guarded expression with the trivial guard.
simpleRhs :: CExpr -> CRhs  Deterministic 
Transforms an expression into a simple unconditional right-hand side.
applyF :: (String,String) -> [CExpr] -> CExpr  Deterministic 
An application of a qualified function name to a list of arguments.
applyE :: CExpr -> [CExpr] -> CExpr  Deterministic 
An application of an expression to a list of arguments.
constF :: (String,String) -> CExpr  Deterministic 
A constant, i.e., an application without arguments.
applyV :: (Int,String) -> [CExpr] -> CExpr  Deterministic 
An application of a variable to a list of arguments.
applyJust :: CExpr -> CExpr  Deterministic 
applyMaybe :: CExpr -> CExpr -> CExpr -> CExpr  Deterministic 
tupleExpr :: [CExpr] -> CExpr  Deterministic 
Constructs a tuple expression from list of component expressions.
ifThenElseExp :: CExpr -> CExpr -> CExpr -> CExpr  Deterministic 
Constructs an if-then-else expression.
letExpr :: [CLocalDecl] -> CExpr -> CExpr  Deterministic 
Constructs a let declaration (with possibly empty local delcarations).
simpleTyped :: CExpr -> CTypeExpr -> CExpr  Deterministic 
Constructs a typed expression from an expression and a simple type.
doExpr :: [CStatement] -> CExpr  Deterministic 
Constructs a do expression.
cBranch :: CPattern -> CExpr -> (CPattern,CRhs)  Deterministic 
Constructs from a pattern and an expression a branch for a case expression.
tuplePattern :: [CPattern] -> CPattern  Deterministic 
Constructs a tuple pattern from list of component patterns.
pVars :: Int -> [CPattern]  Deterministic 
Constructs, for given n, a list of n PVars starting from 0.
pInt :: Int -> CPattern  Deterministic 
Converts an integer into an AbstractCurry expression.
pFloat :: Float -> CPattern  Deterministic 
Converts a float into an AbstractCurry expression.
pChar :: Char -> CPattern  Deterministic 
Converts a character into a pattern.
pNil :: CPattern  Deterministic 
Constructs an empty list pattern.
listPattern :: [CPattern] -> CPattern  Deterministic 
Constructs a list pattern from list of component patterns.
stringPattern :: String -> CPattern  Deterministic 
Converts a string into a pattern representing this string.
list2ac :: [CExpr] -> CExpr  Deterministic 
Converts a list of AbstractCurry expressions into an AbstractCurry representation of this list.
cInt :: Int -> CExpr  Deterministic 
Converts an integer into an AbstractCurry expression.
cFloat :: Float -> CExpr  Deterministic 
Converts a float into an AbstractCurry expression.
cChar :: Char -> CExpr  Deterministic 
Converts a character into an AbstractCurry expression.
string2ac :: String -> CExpr  Deterministic 
Converts a string into an AbstractCurry represention of this string.
toVar :: Int -> CExpr  Deterministic 
Converts an index i into a variable named xi.
cvar :: String -> CExpr  Deterministic 
Converts a string into a variable with index 1.
cpvar :: String -> CPattern  Deterministic 
Converts a string into a pattern variable with index 1.
ctvar :: String -> CTypeExpr  Deterministic 
Converts a string into a type variable with index 1.

Exported operations:

simpleCurryProg :: String -> [String] -> [CTypeDecl] -> [CFuncDecl] -> [COpDecl] -> CurryProg  Deterministic 

Constructs a simple CurryProg without type classes and instances.

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

simpleCCons :: (String,String) -> CVisibility -> [CTypeExpr] -> CConsDecl  Deterministic 

Constructs a simple constructor declaration without quantified type variables and type class constraints.

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

applyTC :: (String,String) -> [CTypeExpr] -> CTypeExpr  Deterministic 

A type application of a qualified type constructor name to a list of argument types.

(~>) :: CTypeExpr -> CTypeExpr -> CTypeExpr  Deterministic 

A function type.

Further infos:
  • defined as right-associative infix operator with precedence 9
  • solution complete, i.e., able to compute all solutions

baseType :: (String,String) -> CTypeExpr  Deterministic 

A base type.

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

listType :: CTypeExpr -> CTypeExpr  Deterministic 

Constructs a list type from an element type.

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

tupleType :: [CTypeExpr] -> CTypeExpr  Deterministic 

Constructs a tuple type from list of component types.

ioType :: CTypeExpr -> CTypeExpr  Deterministic 

Constructs an IO type from a type.

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

maybeType :: CTypeExpr -> CTypeExpr  Deterministic 

Constructs a Maybe type from element type.

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

stringType :: CTypeExpr  Deterministic 

The type expression of the String type.

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

intType :: CTypeExpr  Deterministic 

The type expression of the Int type.

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

floatType :: CTypeExpr  Deterministic 

The type expression of the Float type.

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

boolType :: CTypeExpr  Deterministic 

The type expression of the Bool type.

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

charType :: CTypeExpr  Deterministic 

The type expression of the Char type.

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

unitType :: CTypeExpr  Deterministic 

The type expression of the unit type.

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

dateType :: CTypeExpr  Deterministic 

The type expression of the Time.CalendarTime type.

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

emptyClassType :: CTypeExpr -> CQualTypeExpr  Deterministic 

A qualified type with empty class constraints.

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

cfunc :: (String,String) -> Int -> CVisibility -> CQualTypeExpr -> [CRule] -> CFuncDecl  Deterministic 

Constructs a function declaration from a given qualified function name, arity, visibility, type expression and list of defining rules.

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

cmtfunc :: String -> (String,String) -> Int -> CVisibility -> CQualTypeExpr -> [CRule] -> CFuncDecl  Deterministic 

Constructs a function declaration from a given comment, qualified function name, arity, visibility, type expression and list of defining rules.

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

stFunc :: (String,String) -> Int -> CVisibility -> CTypeExpr -> [CRule] -> CFuncDecl  Deterministic 

stCmtFunc :: String -> (String,String) -> Int -> CVisibility -> CTypeExpr -> [CRule] -> CFuncDecl  Deterministic 

simpleRule :: [CPattern] -> CExpr -> CRule  Deterministic 

Constructs a simple rule with a pattern list and an unconditional right-hand side.

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

simpleRuleWithLocals :: [CPattern] -> CExpr -> [CLocalDecl] -> CRule  Deterministic 

Constructs a simple rule with a pattern list, an unconditional right-hand side, and local declarations.

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

guardedRule :: [CPattern] -> [(CExpr,CExpr)] -> [CLocalDecl] -> CRule  Deterministic 

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 True condition.

noGuard :: CExpr -> (CExpr,CExpr)  Deterministic 

Constructs a guarded expression with the trivial guard.

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

simpleRhs :: CExpr -> CRhs  Deterministic 

Transforms an expression into a simple unconditional right-hand side.

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

applyF :: (String,String) -> [CExpr] -> CExpr  Deterministic 

An application of a qualified function name to a list of arguments.

applyE :: CExpr -> [CExpr] -> CExpr  Deterministic 

An application of an expression to a list of arguments.

constF :: (String,String) -> CExpr  Deterministic 

A constant, i.e., an application without arguments.

applyV :: (Int,String) -> [CExpr] -> CExpr  Deterministic 

An application of a variable to a list of arguments.

applyJust :: CExpr -> CExpr  Deterministic 

applyMaybe :: CExpr -> CExpr -> CExpr -> CExpr  Deterministic 

tupleExpr :: [CExpr] -> CExpr  Deterministic 

Constructs a tuple expression from list of component expressions.

ifThenElseExp :: CExpr -> CExpr -> CExpr -> CExpr  Deterministic 

Constructs an if-then-else expression.

letExpr :: [CLocalDecl] -> CExpr -> CExpr  Deterministic 

Constructs a let declaration (with possibly empty local delcarations).

simpleTyped :: CExpr -> CTypeExpr -> CExpr  Deterministic 

Constructs a typed expression from an expression and a simple type.

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

doExpr :: [CStatement] -> CExpr  Deterministic 

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.

cBranch :: CPattern -> CExpr -> (CPattern,CRhs)  Deterministic 

Constructs from a pattern and an expression a branch for a case expression.

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

tuplePattern :: [CPattern] -> CPattern  Deterministic 

Constructs a tuple pattern from list of component patterns.

pVars :: Int -> [CPattern]  Deterministic 

Constructs, for given n, a list of n PVars starting from 0.

pInt :: Int -> CPattern  Deterministic 

Converts an integer into an AbstractCurry expression.

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

pFloat :: Float -> CPattern  Deterministic 

Converts a float into an AbstractCurry expression.

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

pChar :: Char -> CPattern  Deterministic 

Converts a character into a pattern.

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

pNil :: CPattern  Deterministic 

Constructs an empty list pattern.

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

listPattern :: [CPattern] -> CPattern  Deterministic 

Constructs a list pattern from list of component patterns.

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

stringPattern :: String -> CPattern  Deterministic 

Converts a string into a pattern representing this string.

list2ac :: [CExpr] -> CExpr  Deterministic 

Converts a list of AbstractCurry expressions into an AbstractCurry representation of this list.

cInt :: Int -> CExpr  Deterministic 

Converts an integer into an AbstractCurry expression.

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

cFloat :: Float -> CExpr  Deterministic 

Converts a float into an AbstractCurry expression.

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

cChar :: Char -> CExpr  Deterministic 

Converts a character into an AbstractCurry expression.

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

string2ac :: String -> CExpr  Deterministic 

Converts a string into an AbstractCurry represention of this string.

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

toVar :: Int -> CExpr  Deterministic 

Converts an index i into a variable named xi.

cvar :: String -> CExpr  Deterministic 

Converts a string into a variable with index 1.

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

cpvar :: String -> CPattern  Deterministic 

Converts a string into a pattern variable with index 1.

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

ctvar :: String -> CTypeExpr  Deterministic 

Converts a string into a type variable with index 1.

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