Learn R Programming

rgp (version 0.4-1)

sType: Inference of sTypes

Description

RGP internally infers the sTypes of compound expressions like function applications and function definitions from the sTypes of atomic expressions. The sTypes of building blocks are defined by the user via the %::% operator and are stored in the package-internal global variable rgpSTypeEnvironment. sType calculates the sType of the R expression x. sTypeq quotes its argument x before calling sType. SType inference of function definitions relies on a typed stack of formal arguments of getSTypeFromFormalsStack and setSTypeOnFormalsStack get or set the sType of a formal argument x and a formalsStack, respectively.

Usage

sType(x, typeEnvir = rgpSTypeEnvironment, returnNullOnFailure = FALSE)
configureSTypeInference(constantSTypeFunction = NA)
calculateSTypeRecursive(x, typeEnvir = rgpSTypeEnvironment, formalsStack = list(), returnNullOnFailure = FALSE)
sTypeq(x, typeEnvir = rgpSTypeEnvironment, returnNullOnFailure = FALSE)
getSTypeFromFormalsStack(x, formalsStack)
setSTypeOnFormalsStack(x, value, formalsStack)
hasStype(x)
x %::% value

Arguments

x
The object to operate on.
value
An sType.
typeEnvir
The type environment, containing user-supplied sTypes of building blocks.
formalsStack
A stack of formal arguments with their sTypes.
returnNullOnFailure
Return NULL on failure instead of stopping, defaults to FALSE.
constantSTypeFunction
A function of one parameter to be used to calculate constant types. If set to NA (the default), types of constants are named after the constant's R class.

Details

The function configureSTypeInference is used to configure the type inference engine for special needs.

See Also

sTypeConstructors