Is there a way to compare them? This doesn't work for instance:
(equal? (flat-contract integer?) (flat-contract integer?))
For certain kinds of contracts, you can use contract-equivalent?:
> (contract-equivalent? (flat-contract integer?) (flat-contract integer?))
#true
> (contract-equivalent? (and/c integer? positive?) (and/c integer? positive?))
#true
> (contract-equivalent? (or/c integer? string?) (or/c string? integer?))
#true
This returns #true when the contract system can prove that they are equivalent.
However, as the documentation notes, a #false result doesn't mean that they're not equivalent, it just means it doesn't know:
This function is conservative, so it may return
#falsewhenc1does, in fact, accept the same set of values thatc2does.
> (contract-equivalent? integer? integer?)
#true
> (contract-equivalent? (lambda (x) (integer? x))
(lambda (x) (integer? x)))
#false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With