<div dir="ltr">Excellent! <div>I can't do that in this exact situation (every module counts right now), but in the future that's exactly what I want. Thank you.<div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 6, 2015 at 12:15 AM, Alexis King <span dir="ltr"><<a href="mailto:lexi.lambda@gmail.com" target="_blank">lexi.lambda@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 style="word-wrap:break-word"><div>Why not create an intermediary module? Create a typed module, call it <font face="Courier">typed/data-defn</font>, and use <font face="Courier">require/typed/provide</font> to import the struct and provide it. Then just require that module for all other modules that need to use that struct in a typed context.</div><br><div><blockquote type="cite"><div><div class="h5"><div>On Feb 5, 2015, at 21:10, Benjamin Greenman <<a href="mailto:blg59@cornell.edu" target="_blank">blg59@cornell.edu</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr">I've got three modules:<div>- One untyped module defines some structs</div><div>- One typed module defines some helper functions</div><div>- One typed module does some interesting things</div><div><br></div><div>I've also got a problem: I cannot share imported untyped structs between the typed modules.</div><div><br></div><div>The problem goes away if I linearize the module dependencies, but I'd prefer not to do that -- the situation I have in real life uses two orthogonal modules of helper functions (so the overall inheritance graph is a diamond).</div><div><br></div><div>Here's the minimal example. Can we at least make the error message more helpful?</div><div><br></div><div><div><font face="monospace, monospace">#lang racket/base</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(module data-defn racket/base</font></div><div><font face="monospace, monospace"> (provide (struct-out foo))</font></div><div><font face="monospace, monospace"> (struct foo ()))</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(module utils typed/racket/base</font></div><div><font face="monospace, monospace"> (provide foo->string)</font></div><div><font face="monospace, monospace"> (require/typed (submod ".." data-defn) [#:struct foo ()])</font></div><div><font face="monospace, monospace"> (: foo->string (-> foo String))</font></div><div><font face="monospace, monospace"> (define (foo->string f) "foo"))</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(module main typed/racket/base</font></div><div><font face="monospace, monospace"> (require/typed (submod ".." data-defn) [#:struct foo ()])</font></div><div><font face="monospace, monospace"> (require (submod ".." utils))</font></div><div><font face="monospace, monospace"> (: main (-> Void))</font></div><div><font face="monospace, monospace"> (define (main)</font></div><div><font face="monospace, monospace"> (displayln (foo->string (foo)))))</font></div><div><br></div><div><div><font face="monospace, monospace">;; Type Checker: type mismatch</font></div><div><font face="monospace, monospace">;; expected: foo</font></div><div><font face="monospace, monospace">;; given: foo</font></div><div><font face="monospace, monospace">;; in: (foo)</font></div></div><div><br></div><div><br></div></div></div></div></div>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br></div></blockquote></div><br></div></blockquote></div><br></div>