[racket] tool: show module exports

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Wed Jul 21 23:10:32 EDT 2010

  On 07/21/2010 07:41 PM, Stevie Strickland wrote:
> On Jul 21, 2010, at 9:33 PM, Jon Rafkind wrote:
>> On 07/21/2010 05:26 AM, Robby Findler wrote:
>>> One, non-optimal way to get the contracts is to evaluate the module
>>> and use object-contract on the exports (non-optimal because dependent
>>> contracts will have ...s in them, etc).
>> `object-contract' looks like its only for stuff from the class system, right? Did you mean some other function?
> I believe he meant 'value-contract'.  That'll give you the contract for values that have it stored appropriately, and then you can use 'contract-name' on the contract to get a s-expression representation.

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.