Child pages
  • Typesystem cookbook
Skip to end of metadata
Go to start of metadata

Type equations

Simple case: inference rule for a constant; type of concept instance always equals some concrete type


Example 1: type of instance of integer literal is always instance of IntegerType (int)

Another simple case: inference rule for variable reference; type of concept instance equals to the type of some other node

Example 2

Subtyping

checking, inference, 

Example. conditional ternary operator. Type of condition should be boolean.

Inequality is used here, because in MPS baseLanguage there is a BooleanType (boolean) and ClassifierType Boolean from java and they are weak subtypes of each other.  

If condition evaluates to "true" this operator will be substituted with "toe.ifTrue", so the type of "ifTrue" should be a subtype of the type of operator. The same for "ifFalse".

Another inference example using inequalities: 

Example for each loop

Subtyping 

defining

  • No labels