`FamiliesToPersons` Model Transformation in Clafer
An example FamiliesToPersons
inspired by ATL/Tutorials
- Create a simple ATL transformation. We let the reader appreciate
the simplicity, conciseness, and declarative nature of this
transformation in Clafer.
First, we specify the Family
model.
enum Gender = male | female
Now, let’s create two sample families: the Browns and the Smiths.
Next, we specify the Person
model. Person
s
point to Member
s and have the corresponding first and last
names.
Male
s are persons whose gender is male
.
Analogously, Feamale
s.
Now, we’re ready to specify the actual model transformation which
maps male
Member
s to Male
s and
female
Member
s to Female
s.
When instantiating this model (e.g., using the ClaferIDE), the following result is generated:
=== Instance 1 ===
The inputs
female
male
theBrowns
John
lastName$1 = "Brown"
firstName$1 = "John"
gender$1 = male
familyName$1 = "Brown"
members$1 = John
theSmiths
Alice
lastName$2 = "Smith"
firstName$2 = "Alice"
gender$2 = female
Bob
lastName$3 = "Smith"
firstName$3 = "Bob"
gender$3 = male
familyName$2 = "Smith"
members$2 = Bob
members$3 = Alice
The result
Female = Alice
fName$1 = "Alice"
lName$1 = "Smith"
Male$1 = John
fName$2 = "John"
lName$2 = "Brown"
Male$2 = Bob
fName$3 = "Bob"
lName$3 = "Smith"