Structural Types with MPS


I'm trying to implement an editor for the roy language (or something close - depending on where I will end). Roy (http://roy.brianmckenna.org/) uses structural types. Here two objects have the same type if they have the same structure (the same properties with the same type). See below for an example.

type Person = {firstName: String, lastName: String}
let getName (x: Person) = x.firstName ++ " " ++ x.lastName 

console.log (getName {firstName: "Brian", lastName: "McKenna"})

// Won't compile:
// console.log (getName {})

I haven't found out how to do this with the MPS type system as I can only assign a type node to some expression. Any hints would be great.

Regards, Jan


Please sign in to leave a comment.