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

Add data type guards #513

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

eutro
Copy link
Contributor

@eutro eutro commented Oct 5, 2021

Adds #:guard-maker arguments for tuple, wrapper and record types, as well as <type>-guard-maker/c macros for creating these from contracts.

Since these are all implemented in terms of just the tuple type and its guard implementation, and is also somewhat repetitive, I believe it makes most sense to have all of these in a single PR.

Implements #42, and its subtasks: #202, #203, #204.

Supercedes #512. and the same caveat applies for the <type>-guard-maker/c macros: they may not be the best for applying contracts, since the calling party is not known to the guard procedure, and thus it has to take any blame for contract violations itself.

Copy link

@zyrolasting zyrolasting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the documentation, I see @racket appear where @racketid might make more sense. That is, on identifiers assumed to be bound to no particular value for discussion purposes.

This is off topic for the PR, but you might introduce their use within your side of the diff in the manual. Either that or just open a different PR dedicated to the purpose.

sorted alphabetically by field name, and the values it returns will be the
values stored in the record.

By default, record types are

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might just be an artifact of a rewrap, but this line seems to end too soon.

created with properties that make them print like transparent structures,
except field names are included --- see @racket[default-record-properties] for
details.}

@defform[(record-guard-maker/c keyword-contract-pair ...)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unintentional blank?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not unintentional but maybe unnecessary.

@eutro
Copy link
Contributor Author

eutro commented Oct 26, 2021

I think all of the @racket-referenced identitiers are bound, at least, building the docs doesn't cause any errors with them.

@jmhimara
Copy link

Just stumbled onto this and just wandering what the status is? It would be a nice feature to have.

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.

3 participants