-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add boolean contract combinators to the stdlib #1995
Conversation
I think |
Yeah, it's hard to think of a good, natural use-case. I imagine they might exist. Let's implement it lazily: wait for someone to come with a need for it. Otherwise, it's ready to review now @jneem (sorry about the early ping, I requested your review too soon, before adding tests) |
01ca07a
to
375dccd
Compare
🎉 All dependencies have been resolved ! |
This commit adds the boolean combinators `one_of`, `not` and `all_of` to the contract module of the stdlib. They are implemented in the obvious way, by making immediate decisions based on the immediate part of their contract operands. The limitations and possible work arounds are detailed in the documentation and in the manual.
Co-authored-by: jneem <joeneeman@gmail.com>
Make a pass on the new documentation of boolean contract combinators to implement the reviewer's suggestions.
78b877c
to
b6e3b8e
Compare
Depends on #1987
This commit adds the boolean combinators
one_of
,not
andall_of
to the contract module of the stdlib. They are implemented in the obvious way, by making immediate decisions based on the immediate part of their contract operands. The limitations and possible work around are detailed in the documentation and in the manual.I considered the addition of
one_of
, to adhere to the JSON schema terminology, but it turns out that it seems pretty useless for the time being, because record contracts are mostly delayed and I couldn't come up with a simple compelling example that would work in the current setting, whereone_of
would be needed overany_of
. The standard example is two record contracts with an non-empty intersection, like{employee_id, name, ..}
and{student_id, name, ..}
, but this can't work as expected currently as the check for missing fields is delayed. I suspect we need to wait for proper full eager versions of builtin record contracts for a simple example (one can write the previous example with specialized custom contracts, but it starts to be involved - the fact that I can't come up with a short example to put in the documentation of the function leads me to think that it's too early to introduce this function)