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

~t has incorrect contract? #49

Open
michj opened this issue Apr 5, 2021 · 1 comment
Open

~t has incorrect contract? #49

michj opened this issue Apr 5, 2021 · 1 comment
Labels
doc Documentation fix / enhancement

Comments

@michj
Copy link

michj commented Apr 5, 2021

The documentation for (~t) states that the contract is:
(or/c time-provider? date-provider?)
but on passing it a date there is a contract violation:

  ~t: contract violation
  expected: (and/c time-provider? date-provider?)
  given: #<date 2009-12-21>
  argument position: 1st
  other arguments...```
@97jaz 97jaz added the doc Documentation fix / enhancement label Apr 5, 2021
@97jaz
Copy link
Owner

97jaz commented Apr 5, 2021

The contract in the documentation isn't precise enough. What ~t really does is ask each of the atomic patterns what their contracts are and then enforces the conjunction of them all. Or, to put it plainly: if you include time patterns, like hour-of-day, in your pattern, then it will require that the temporal object be a time-provider. If you use date patterns, like year, it will require that the temporal object be a date-provider. If you use both, it needs to be both.

I should definitely discuss this in the documentation. I could use suggestions on how to state the (formal) contract, though.

Maybe I just shouldn't have used a single function for all of these cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Documentation fix / enhancement
Projects
None yet
Development

No branches or pull requests

2 participants