[racket] style guide, was Re: Contracts and submodules

From: Greg Hendershott (greghendershott at gmail.com)
Date: Tue Mar 5 20:43:06 EST 2013

> Note that in his "decluttering" example, his module+ submodule
> does a (require (submod "..")). It turns out that a submodule
> that does this will get the contracted identifiers instead of the
> original ones (since `require` is allowed to overwrite bindings
> from the module's base module).

Ah! I misunderstood it to be more complicated and thought I'd read
module* not module+.

But it's utterly simple.

In files that have many module+ forms interleaved with what they test,
I've already been putting a module+ near the top simply to require
rackunit:

(module+ test
  (require rackunit))

This simply needs to become:

(module+ test
  (require rackunit (submod "..")))

And bingo.

Awesome. Thank you.

On Tue, Mar 5, 2013 at 6:51 PM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:
> On 2013-03-05 17:48:51 -0500, Greg Hendershott wrote:
>> But it seems like the only choices are:
>>
>> - Keep using (provide (contract-out)) but switch back to lumping all
>> the tests together, in one module* (or even back to the old way of a
>> separate file).
>
> I think Matthias's solution was actually to let you use
> (provide (contract-out)) while still using module+ to group tests
> together.
>
> Note that in his "decluttering" example, his module+ submodule
> does a (require (submod "..")). It turns out that a submodule
> that does this will get the contracted identifiers instead of the
> original ones (since `require` is allowed to overwrite bindings
> from the module's base module).
>
> Cheers,
> Asumu

Posted on the users mailing list.