[plt-scheme] low-level contract constructors
In parameter.plt I have a struct-as-procedure called a pseudo-parameter
with a high-order contract constructor pseudo-parameter/c. I discovered
a couple little issues with the scheme/contract library in the process.
- The undocumented `proj-get' procedure seems necessary for a
higher-order contract constructor, since you need to use the projection
of the underlying contract in building the new one.
- The `flat-proj' procedure isn't exported from scheme/contract, but
it's also needed for a higher-order contract, in case the underlying
contract is flat. So I copied its definition from contract-guts.ss and
pasted it into my module.
Robby, if by chance you have a moment, could you take a look at
http://planet.plt-scheme.org/package-source/dherman/parameter.plt/1/3/main.ss
and tell me if pseudo-parameter/c looks plausible? It seems to work for
the test cases I've tried, but it's a little confusing so I'm not sure
I've got it right. Particularly the call to ((proj-get c) c) looks
weird. Also, I seem to be getting the object-name wrong when wrapping a
function contract, e.g.:
(module a scheme
(require (planet dherman/parameter:1:3))
(define p
(let ([f add1])
(make-pseudo-parameter
(lambda () f)
(lambda (g)
(set! f g)))))
(provide/contract [p (pseudo-parameter/c (-> number? number?))]))
> (require 'a)
> (p)
#<procedure:unsaved-editor4117:9:47>
Thanks so much,
Dave