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

Sets #543

Open
sstone1 opened this issue Nov 7, 2022 · 3 comments
Open

Sets #543

sstone1 opened this issue Nov 7, 2022 · 3 comments

Comments

@sstone1
Copy link
Contributor

sstone1 commented Nov 7, 2022

Currently in a Concerto model, it is not possible to define a field as being a set - a collection of unique values.

Feature Request ๐Ÿ›๏ธ

Allow a model author to define a field as being a set, and at validation time enforce uniqueness on the values in stored in that set.

Use Case

Imagine a model that backs a multiple choice question in a survey, such as "Which of these fruits do you like?".

The fruits could be modelled as an enumeration:

enum Fruit {
  o APPLE
  o PEAR
  o BANANA
  o MANGO
}

Today, all you can do is model the list of fruits you like as a list:

concept Survey {
  o Fruit[] fruits
}

But there is nothing in the model to say that you only want to allow unique fruit values in the list, so you could have:

{
  "$class": "Survey",
  "fruits": [
    "APPLE",
    "APPLE",
    "APPLE",
    "APPLE"
  ]
}

Possible Solution

A few syntax options spring to mind:

  1. Some kind of generics-like way of expressing a Set type:
concept Survey {
  o Set<Fruit> fruits
}
  1. A uniqueness constraint on a list
concept Survey {
  o Fruit[] fruits unique
}

I would suggest that whatever we do, we restrict the type of values in a set to primitive types and enumerations.

Context

Detailed Description

@sstone1 sstone1 added the Type: Feature Request ๐Ÿ›๏ธ New feature or request label Nov 7, 2022
@mttrbrts
Copy link
Member

mttrbrts commented Nov 7, 2022

I like it, this feature would pair nicely with #447

@mttrbrts mttrbrts moved this to This Quarter in Concerto Roadmap Dec 9, 2022
@mttrbrts mttrbrts moved this from Next 3 Months to Next 6 Months in Concerto Roadmap Dec 9, 2022
@mttrbrts mttrbrts moved this from Next 6 Months to Next 12 Months in Concerto Roadmap Feb 27, 2024
@mttrbrts
Copy link
Member

There is a language design for this feature at https://github.com/accordproject/concerto/wiki/Aggregate-Types-Design-(Working-Draft)

Copy link
Contributor

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Next 12 Months
Development

No branches or pull requests

2 participants