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

Set data type #1735

Open
toastal opened this issue Dec 4, 2023 · 3 comments
Open

Set data type #1735

toastal opened this issue Dec 4, 2023 · 3 comments

Comments

@toastal
Copy link

toastal commented Dec 4, 2023

Is your feature request related to a problem? Please describe.
For collection types, Nickel supports: records, dictionary, arrays, but one common structure missing is Set, an unordered collection like an array where all values must be unique. Uniqueness can prevent certain kinds of errors where the consumer should need to consider duplicate values, but also comes with a grab bag of handy combinators like union, intersect, difference, merge, etc.

Describe the solution you'd like
Add a new data type: Set T + stdlib module std-set

Describe alternatives you've considered
Making a bunch of contracts around Array T.

Additional context
This is a common data structure in most languages. It’s been a long personal pain point with its absence in JSON, however alternatives like EDN do support it. Being able to assert a JSON Array as a Set would be very useful.

@yannham
Copy link
Member

yannham commented Dec 14, 2023

I wonder, do you want a builtin type Set that would be natively handled by Nickel, or some kind of standard library module that implements Set using more basic constructions? Or, maybe, you don't care and just want Set 🙂

@toastal
Copy link
Author

toastal commented Dec 14, 2023

Sets are also basic blocks for building more advanced compound types too

@suimong
Copy link
Contributor

suimong commented Dec 20, 2023

Weighing in here as someone who also encountered use cases for Set, I believe a native implementation would be nicer, though the only reason I could think of is performance.😂

@toastal toastal changed the title Sets data type Set data type Jan 2, 2024
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

No branches or pull requests

3 participants