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] hash table confusion

2013-12-28 Thread Sam Tobin-Hochstadt
While your answer is what Manfred is looking for, I still find the original behavior worrying. It lets you expose the internals of opaque data structures without having the relevant inspector. Sam On Dec 28, 2013 4:16 PM, "J. Ian Johnson" wrote: > You want to make sure your structs are inspectab

Re: [racket] hash table confusion

2013-12-28 Thread Manfred Lotz
On Sat, 28 Dec 2013 17:15:25 -0500 (EST) "J. Ian Johnson" wrote: > You want to make sure your structs are inspectable. You can define > your structs with the #:transparent option or define your own > equality relation with the gen:equal+hash generic interface. -Ian Aah, ok I got it. In my sourc

Re: [racket] hash table confusion

2013-12-28 Thread J. Ian Johnson
You want to make sure your structs are inspectable. You can define your structs with the #:transparent option or define your own equality relation with the gen:equal+hash generic interface. -Ian - Original Message - From: Manfred Lotz To: users@racket-lang.org Sent: Sat, 28 Dec 2013 15:4

Re: [racket] define-match-expander

2013-12-28 Thread Alexander D. Knauth
I just wrote a match-expander that does something like that: (check-equal? (match 1 [(my-pat n:num) n]) 1) (check-equal? (match 'x [(my-pat n:num) n] [_ 2]) 2) like this: #lang racket (require rackunit) (require (for-syntax (only-in lang/htdp-intermediate-lambda st

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
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] define-match-expander

2013-12-28 Thread Alexander D. Knauth
I'm not sure why this works and that doesn't, but try passing n as an argument to the match expander: #lang racket (require rackunit) (define-match-expander num: (λ(stx) (syntax-case stx () [(num: n) #'(? number? n)]))) (check-equal? (match 1 [(num: n) n]) 1) (check-equal? (ma

[racket] hash table confusion

2013-12-28 Thread Manfred Lotz
I have a hash table (created by using make-hash) where the key is a struct. This seems to work fine although the documentation says The make-hash procedure creates a table where keys are compared with equal?,... and it seems that equal? gives #f if I compare two structs having the same conte

Re: [racket] How to view source code of procedures? MIT scheme "pp" equivalent?

2013-12-28 Thread Scott Klarenbach
Matthias, I'm likely very misguided here and really just learning by hacking around, so bare with me :). I'm playing around with the idea of a sort of "Language Integrated Query" like LINQ. For example: > (sql (query 'my-table #:where (λ (row) (> (hash-ref row 'id) 3 "select * from my-

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] [racket-dev] downtime

2013-12-28 Thread Robby Findler
We have also looked into the cause and are working to avoid this particular failure mode. We're sorry about this and are working to avoid it going forward. Robby On Sat, Dec 28, 2013 at 8:45 AM, Matthias Felleisen wrote: > > As some of you may have noticed, we experienced a day of downtime thi

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

[racket] downtime

2013-12-28 Thread Matthias Felleisen
As some of you may have noticed, we experienced a day of downtime this week. It was due to a brief power outage and a slight misconfiguration of the server. Eli will filter the mail queues so that messages about the outage are kept to a minimum. -- Matthias