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

Added type alias to constrain values to a set #137

Merged
merged 2 commits into from
Jun 16, 2023

Conversation

ajaychandran
Copy link
Contributor

Fix for #133

@Iltotore
Copy link
Owner

Iltotore commented Jun 16, 2023

What about something like:

type In[V <: Tuple] = V match
  case EmptyTuple => False
  case h *: t => StrictEqual[h] | In[t]

This would allow In[EmptyTuple]. Probably not useful in most of use cases but technically correct.

Can you add some tests too in AnySuite?

@Iltotore Iltotore linked an issue Jun 16, 2023 that may be closed by this pull request
@ajaychandran
Copy link
Contributor Author

This would allow In[EmptyTuple]. Probably not useful in most of use cases but technically correct.

Yes but I prefer Making Impossible States Impossible.

Will add tests.

@Iltotore
Copy link
Owner

I'd argue it's not an "impossible" state but just a case that will always return false. Nonetheless, it is easier to remove this "restriction" in the feature than adding it then realizing it was a bad call.

Let's keep your original implementation 👍

@Iltotore Iltotore merged commit 7f3430f into Iltotore:main Jun 16, 2023
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.

Improve usability for value constrained by a set
2 participants