[racket] Making a contract between a function and "the world in general"
Using define/contract or a contract region, we can make a function with
a contract between the function and the module. If the function is
provided and a requiring module applies bad arguments, the module gets
blamed.
Or we can use (provide (contract-out ...)) instead, and make a contract
between the module and whatever requires the module. If a requiring
module applies bad arguments, the requiring module gets blamed.
I'd like to make a function with a contract between the function and the
world in general, where if anything applies bad arguments - whether in
the defining module or out of it - it gets blamed. Is there a way to do
that besides using both define/contract and contract-out, and
duplicating the contract?
Is there a way to "lift" contracts to the module level?
I think of it in analogy to this:
#lang racket/load
(module provider0 racket
(define (takes-a-list xs) (void))
(provide/contract (takes-a-list ((listof real?) . -> . void?))))
(module provider1 racket
(require 'provider0)
(provide (all-from-out 'provider0)))
(require 'provider1)
(takes-a-list (λ (x) x))
Here, provider1 isn't blamed for the bad argument, even though it
provided it.
Neil T