Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named product properties in generated code #22

Merged
merged 5 commits into from
Jul 15, 2020
Merged

Conversation

dlurton
Copy link
Member

@dlurton dlurton commented Jul 15, 2020

This does not change the s-expression representation of products but changes the type universe grammar to require names for elements of products. Previously they were only required for records. The names will be used for the Kotlin properties which represent those elements.

The reason for this change is to improve the readability of the generated code. The unreadability of the synthetic names became very apparent in this PR, where for example, the synthetic name "expr2" is used to represent a let-body on a PIG-generated product type.

After this change, product elements are given names which are used only in the generated code.

This represents a somewhat significant change in the grammar of type universe files, even if it is a simplification. Namely, within sum types, the keyword product or record must now be used to indicate the type of variant-tuple. PIG used to detect the type of tuple by the syntax that was in use, but now that both products and records both require their elements to be named, another method was required.

// OLD product defintion:
(product int_pair int int)

// NEW product definition:
(product int_pair (first int) (second int))

// OLD sum definition:
(sum entity
    (slug)
    (android int)
    (human 
           (first_name symbol)
           (last_name symbol)
           (title (? symbol))  
           (parent (? entity))))     

// NEW sum definition:
(sum entity
    (product slug)
    (product android (unique_id int))
    (record human 
           (first_name symbol)
           (last_name symbol)
           (title (? symbol))  
           (parent (? entity))))     

Start by reviewing the changes in README.md, and review the rest in the order of your preference.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dlurton dlurton requested review from therapon and almann July 15, 2020 02:06
@dlurton dlurton self-assigned this Jul 15, 2020
dlurton and others added 3 commits July 15, 2020 14:52
Co-authored-by: Therapon Skoteiniotis <therapon@users.noreply.github.com>
Co-authored-by: Therapon Skoteiniotis <therapon@users.noreply.github.com>
@dlurton dlurton merged commit fa24c55 into master Jul 15, 2020
@dlurton dlurton deleted the named-product-properties branch July 23, 2020 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants