[racket] TR Submodules

From: Ray Racine (ray.racine at gmail.com)
Date: Mon Nov 19 10:18:07 EST 2012

I'd originally written some cooperating macros in untyped Racket using
granularly structured in submodules as many aspects ended up being required
at meta 0 and reused again at meta 1 for the macros.  That was pretty

When I tried to TR things I started to hit the submodule issue.  However as
Neil indicated if you avoid having TR submodules in a TR language top level
module, and when necessary refactor things into their own source file, it
all works out.  Not quite as neat if submodules worked completely in all
their glory, but all-in-all not bad.

In other words I was able to do everything a needed/wanted to do with
regard to syntax/parse macros in TR.  I had a few palpitations going in on
whether one could write macros in TR code which expanded into TR syntax.
Turns out it all works quite smoothly other than the noted submodule issue.

TR + Syntax/Parse is the shiniest of new hammers, must resist making
everything a macro.  Or not.

On Sun, Nov 18, 2012 at 9:39 PM, Neil Toronto <neil.toronto at gmail.com>wrote:

> On 11/18/2012 07:02 PM, Ray Racine wrote:
>> #lang typed/racket
>> (provide x)
>> (module M typed/racket
>>    (provide x)
>>    (define: x : Natural 3))
>> (require (submod "."  M))
>> ;; end-of-file
>> ...
>> Has anyone had a chance to look into this yet?  I'd love to use
>> submodules in TR.
> As a workaround, you can change the parent module's language to "racket"
> and your specific example will work just fine. You don't have to worry
> about extra contract checks, because the identifier `x' won't have a
> contract on it unless it's used in untyped code, even though it's provided
> by untyped code.
> IOW, if your parent module above is named "x.rkt", you can write this:
> #lang typed/racket
> (require "x.rkt")
> x
> TR is smart enough to not put a contract on `x'. (I don't think it would
> in this case anyway, but pretend `x' is a function. It still wouldn't have
> a contract.)
> The array library uses typed submodules a lot, mostly to define typed
> values and untyped macros that expand to those values in the same file. I
> did have to split files in a few cases, because I ran into problems having
> two typed submodules in the same parent module.
> I'll let someone else explain that fundamental problem that seems to
> require rewriting the macro expander to fix it. I also won't speculate on
> whether that will happen soon.
> Neil ⊥
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/**users <http://lists.racket-lang.org/users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121119/2e26ffdd/attachment.html>

Posted on the users mailing list.