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

Dedicated choice types #797

Open
SimonCockx opened this issue Jul 25, 2024 · 0 comments
Open

Dedicated choice types #797

SimonCockx opened this issue Jul 25, 2024 · 0 comments
Labels
enhancement New feature or request subject: syntax This issue is about the syntax of Rosetta

Comments

@SimonCockx
Copy link
Contributor

See part 3 of #747 (comment).

3. Support dedicated choice types (remove syntactic sugar), add support for switch expressions, support accessing common attributes with ->, and support (de)serialisation with @type (except for basic types).

A couple of things change at this point.

  1. A basket can now directly be passed to a function expecting an asset, instead of wrapping it in Asset { basket: basket, ... }. The Asset {...} constructor syntax disappears.
  2. Accessing common attributes in choice types changes from ->> to ->. For one-of types, the ->> syntax stays the same.
  3. Discriminating a choice type now must happen by using a switch. All checks of the form if asset -> basket exists then will need to be refactored. E.g.,
    asset switch
      Basket then <item is now of type Basket>,
      Loan then <item is now of type Loan>,
      Security then <item is now of type Security>,
      default then <optional default case>
    
    Nested choice types are flattened out.
  4. Serialisation becomes less nested. E.g., what used to be
    {
      "Basket": {
        "identifier": "abc123"
        "basketAttribute": 42
      }
    }
    
    now becomes
    {
      "@type": "Basket",
      "identifier": "abc123",
      "basketAttribute": 42
    }
    

Note that this can only be done after the migration to Translate 2.0.

@SimonCockx SimonCockx added enhancement New feature or request subject: syntax This issue is about the syntax of Rosetta labels Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request subject: syntax This issue is about the syntax of Rosetta
Projects
None yet
Development

No branches or pull requests

1 participant