Got stuck with making a type system

Hi, I'm an MPS newbie using v3

I am trying to create something similar to the money sample by myself. I have the basics all working. Now I want to define an exchange rate conversion operator. I made a new concept that extends Expression which takes an expression along with a currency (enum type). The editors all work as I expect.

However, without a type system, I can write erroneous code like

String a = 10 EUR in USD;


Money m = "bob" in EUR;

Trying to fix the latter issue first, I made a type system rule. I thought I wanted something like this:

typeof(exchangeRateConversionOperator.expr) :==: <MoneyLiteral>;

however inside the quotation I can't see any of my concepts, or indeed anything from my model. Only stuff from baseLanguage shows up.

I'm obviously making some conceptual mistake here. Why can't I tell MPS that the left hand part of the operator must be some kind of money (or any expression that is of type MoneyLiteral)?
You need to add dependency to your language to the model (Ctrl+L or Ctrl+R). Also, it might be a better solution to use SNode or builders languages instead of quotation.
Thanks. I don't see why it's better to use Snode/builders lang, also I don't understand how I'd do that. Is this related to the need to avoid circular dependencies (with "light quotations"?). It's very much non obvious to me, why I have to import the language I'm working on into itself in order to write type system rules!!

Please sign in to leave a comment.