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 seamless.<br>
<br>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. <br>
<br>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. <br>
<br>TR + Syntax/Parse is the shiniest of new hammers, must resist making everything a macro. Or not.<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 18, 2012 at 9:39 PM, Neil Toronto <span dir="ltr"><<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 11/18/2012 07:02 PM, Ray Racine wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
#lang typed/racket<br>
<br>
(provide x)<br>
<br>
(module M typed/racket<br>
(provide x)<br>
(define: x : Natural 3))<br>
<br>
(require (submod "." M))<br>
<br>
;; end-of-file<br>
<br></div>
...<div class="im"><br>
<br>
Has anyone had a chance to look into this yet? I'd love to use<br>
submodules in TR.<br>
</div></blockquote>
<br>
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.<br>
<br>
IOW, if your parent module above is named "x.rkt", you can write this:<br>
<br>
#lang typed/racket<br>
(require "x.rkt")<br>
x<br>
<br>
<br>
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.)<br>
<br>
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.<br>
<br>
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.<br>
<br>
Neil ⊥<br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a><br>
</blockquote></div><br></div>