-
Notifications
You must be signed in to change notification settings - Fork 261
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
Use SubSet type as constructor #1577
Comments
Thanks for suggesting improvements. I see the value when the datatype has only one constructor and that constructor has the same name, but this is a narrow case.
|
Leaving this here: we can make the requirement regarding Another way I might think about it would be to be able to extract the requirements about the SubSet type Perhaps we could use |
To extract the requirements about the subset type, you can already do this:
Were you thinking of something else? |
Yes. The above is a static check. What if I am making (or given) a Foo from arbitrary data that I can not reason about statically?
It is obviously possible to do because I can investigate what the condition is that makes something a |
Oh, I see. Actually, it looks like you are defining a use case that would go along this PR: In this PR, we explicitly allow the use of subset types in comprehensions, and we compile the condition in the loop. We can do this because if the subset constraint is not satisfied, we can just skip the element. The problem of doing it on one single element is the failure handling. If you say it cannot be checked statically and you want a dynamic check, since Dafny is meant to be sound, it has to handle failure gracefully. In this case, you would use the elephant operator
|
It would be nice to be able to just use a SubSet type in the same way as the underlying
datatype
.The text was updated successfully, but these errors were encountered: