[racket] tool: show module exports

From: Stevie Strickland (sstrickl at ccs.neu.edu)
Date: Thu Jul 22 12:33:16 EDT 2010

Yeah, I do know that.  We only hang the contracts on things that are wrapped.  This means that you'll also see the same behavior on contracts that involve immutable data structures.  For example, for the module:

#lang racket
(provide/contract [fun-list (listof (-> any/c any/c))])
(define fun-list (list zero? add1 sub1))

If you just try running (value-contract fun-list), you'll get #f, but if you walk the list, you'll notice that each element does have a contract.  So if you want to really reconstruct all the contracts this way, you might need to do some smarter things with immutable data structures.  Howevr, even if you do that, I think you'll end up with either false positives or false negatives.  For the former, someone might have just stored a contracted value in the list along with other, non-contracted values.  For the latter, if you have contracts that work on both immutable and mutable values (as some work I'm doing on the side does for things like hash tables), then you'll see the contracts on the mutable values, but not on the immutable ones.

Stevie

On Jul 21, 2010, at 11:10 PM, Jon Rafkind wrote:
> Ah ok, thats what I thought he meant. I tried `value-contract' but I stupidly made this too-simple test-case
> 
> #lang racket
> (provide/contract (foo number?))
> (define foo 2)
> 
> And when I called (value-contract foo) I got #f, but when I changed the contract to something that persists passed the boundaries of the module (like a function)
> 
> #lang racket
> (provide/contract (foo (-> any/c any/c)))
> (define (foo x) x)
> 
> > (contract-name (value-contract foo))
> '(-> any/c any/c)
> 
> Of course you knew all that, just thought I'd be pedagogic!




Posted on the users mailing list.