Description The goal of this module is to provide:
The # operator will always produce a value of type[&T], where &T is bound to the type that was reified.
The following functions are provided on types:
- Attr: Attributes register additional semantics annotations of a definition.
- choice: Choice between alternative productions.
- comparable: Check if two types are comparable, i.e., have a common supertype.
- eq: structural equality between values.
- equivalent: Check if two types are equivalent.
- Exception:
- glb: The greatest lower bound (glb) between two types.
- isADTType: Determine if the given type is an Abstract Data Type (ADT).
- isAliasType: Determine if the given type is an alias.
- isBagType: Determine if the given type is a bag (bags are not yet implemented).
- isBoolType: Determine if the given type is a bool.
- isConstructorType: Determine if the given type is a constructor.
- isDateTimeType: Determine if the given type is a
datetime
.
- isFunctionType: Determine if the given type is a function.
- isIntType: Determine if the given type is an int.
- isListRelType: Determine if the given type is a list relation.
- isListType: Determine if the given type is a list.
- isLocType: Determine if the given type is a loc.
- isMapType: Determine if the given type is a map.
- isNodeType: Determine if the given type is a node.
- isNumType: Determine if the given type is a num.
- isRatType: Determine if the given type is a rational.
- isRealType: Determine if the given type is a real.
- isReifiedType: Determine if the given type is a reified type.
- isRelType: Determine if the given type is a relation.
- isSetType: Determine if the given type is a set.
- isStrType: Determine if the given type is a string.
- isTupleType: Determine if the given type is a tuple.
- isTypeVar: Determine if the given type is an type variable (parameter).
- isValueType: Determine if the given type is a value.
- isVoidType: Determine if the given type is a void.
- lub: The least-upperbound (lub) between two types.
- make: instantiate an ADT constructor of a given type with the given children
- Production: A production in a grammar or constructor in a data type.
- subtype:
- Symbol: A Symbol represents a Rascal Type.
- typeOf: returns the dynamic type of a value as a reified type
- var-func:
Examples rascal>#int
type[int]: type(
int(),
())
rascal>#rel[int,int]
type[rel[int,int]]: type(
rel([
int(),
int()
]),
())
rascal>data B = t();
ok
rascal>#B
type[B]: type(
adt(
"B",
[]),
(adt(
"B",
[]):choice(
adt(
"B",
[]),
{cons(
label(
"t",
adt(
"B",
[])),
[],
[],
(),
{})})))
rascal>syntax A = "a";
ok
rascal>#A;
type[sort("A")]: type(
sort("A"),
(
layouts("default"):choice(
layouts("default"),
{prod(
layouts("default"),
[],
{})}),
empty():choice(
empty(),
{prod(
empty(),
[],
{})}),
sort("A"):choice(
sort("A"),
{prod(
sort("A"),
[lit("a")],
{})})
))
rascal>type(\int(),())
type[value]: type(
int(),
())