[racket] contracts on functions that take arbitrary keyword arguments

2013-12-27 Thread Alexander D. Knauth
I want to make contracts on some apply-like functions that check some arguments but just passes all the others (including keyword arguments) on to a function (provided as an argument). If there weren't any keyword arguments, I could use a rest argument to do this, but that wouldn't work wi

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-27 Thread Matthias Felleisen
This is a bit vague. Can you clarify the question with a concrete example? On Dec 26, 2013, at 7:45 PM, "Alexander D. Knauth" wrote: > I want to make contracts on some apply-like functions that check some > arguments but just passes all the others (including keyword arguments) on to > a fun

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-27 Thread Robby Findler
Use make-keyword-procedure? Robby On Thursday, December 26, 2013, Alexander D. Knauth wrote: > I want to make contracts on some apply-like functions that check some > arguments but just passes all the others (including keyword arguments) on > to a function (provided as an argument). If there we

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-27 Thread Alexander D. Knauth
The problem isn't with defining the function, the problem is with making a contract for it. I can define the function fine, I just don't know how to write a contract for it. I used make-keyword-procedure to define the function, but is there something like make-keyword-procedure- contract?

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-28 Thread Matthias Felleisen
1. I am stumped. I don't know how to write a contract for my-send. 2. I see what you want to do and I think you should seriously consider a different protocol: (define (get-vector this) (vector (send this get-x) (send this get-y))) For something like get-vector, I'd create a contract cons

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-28 Thread Robby Findler
I think you probably could make a contract that did what you were talking about in the first message in this thread, but you cannot do it with any of the existing contract combinators (->, ->*, case->, ->i, etc). You would have to use the lower-level, projection-based api to make a new combinator.

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-28 Thread Alexander D. Knauth
What's the lower-level, projection-based api and how do I use it? On Dec 28, 2013, at 11:50 AM, Robby Findler wrote: I think you probably could make a contract that did what you were talking about in the first message in this thread, but you cannot do it with any of the existing contract com

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-28 Thread Robby Findler
http://docs.racket-lang.org/reference/Building_New_Contract_Combinators.html?q=racketcontract (But there is a new interface (the old one will continue to work of course) in the git version) Let me know if you have questions or get stuck and I'll try to improve the docs. Robby On Sat, Dec 28, 2

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-28 Thread Alexander D. Knauth
This is my first try at making something like a make-keyword-procedure- contract. Any suggestions or things I did wrong? By the way it doesn't seem like a good idea to put separate contracts on the kws and kw-args, but that's what I did for now because I don't need to check anything about the

Re: [racket] contracts on functions that take arbitrary keyword arguments

2013-12-29 Thread Matthias Felleisen
Rackety but otherwise okay #lang racket (require rackunit) (define (make-keyword-procedure-contract kws/c kw-args/c rest/c range/c) (define all-contracts (list kws/c kw-args/c rest/c range/c)) (make-contract #:name `(make-keyword-procedure-contract ,@all-contracts) #:first-order proc