~t has incorrect contract?
michj opened this issue · 1 comments
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...```
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.