<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I think you’re reading too far into what I’m proposing, though I admit I probably didn’t give enough context. I’ve been talking with Sam about this issue on IRC, so he knows what I’m talking about, but I’ll try and clarify here.</div><div class=""><br class=""></div><div class="">This entire thing is just a fix for the problem described in <a href="http://lexi-lambda.github.io/racket-parametric-opaque-types/#(part._.Extending_parametricity_to_opaque_types)" class="">Section 2</a>. When using require/typed to import “opaque” types from untyped code, the imported types cannot be polymorphic. This entire proposal is simply a way to make that possible.</div><div class=""><br class=""></div><div class="">In Section 2.1, <font face="Courier" class="">A</font> is used in a number of places, but it is just a type parameter. See the typed struct definition in Section 1. <font face="Courier" class="">A</font> does not refer to a specific type but any type. <font face="Courier" class="">Posn</font> essentially becomes a new type combinator than can make new types by supplying it with any other type.</div><div class=""><br class=""></div><div class="">The other functions imported in Section 2.1 simply make use of Typed Racket’s polymorphic type utilities to make use of the fact that <font face="Courier" class="">Posn</font> is now a polymorphic type. The concepts here are simple. No semantics are being changed, it’s just extending parameterization to opaque types.</div><div class=""><br class=""></div><div class="">Sections 2.3 and 2.2, in contrast, are simply describing mechanisms for implementing the functionality outlined in 2.1.</div><div class=""><br class=""></div><div class="">Now to answer your points.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">- Should an A only be a base type like String or Symbol</div></div></blockquote><br class=""></div><div class=""><font face="Courier" class="">A</font> can by any type. It’s a type parameter. <font face="Courier" class="">(Posn A)</font> is like <font face="Courier" class="">(Boxof A)</font>.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">- Do you mean to infer the type of the first thing put into the struct as the exact type for everything else?</div></div></blockquote><br class=""></div><div class="">No, not really. Remember that <font face="Courier" class="">Posn</font> is an <i class="">opaque type</i>. TR has no idea it’s actually implemented as a struct. Perhaps the JSExpr example given in Section 3 will help to illustrate that generality. This will just leverage the existing polymorphic type inference mechanisms TR already provides.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">- Would "first class members" prevent me from filling a struct with members of (define-type (Option A) (U 'None (Some A))), where "Some" is a struct with one field?</div></div></blockquote><br class=""></div><div class="">No, as I said, you can supply any type for <font face="Courier" class="">A</font>. By “first class member” of the type system, I simply meant that these types would have to be built-in to TR as a special case—they cannot be derived from the existing type constructs provided by TR. This is similar to how structure types are “first class” in TR—the <font face="Courier" class="">struct</font> form is “magical” and cannot be reimplemented in terms of other TR primitives.</div><div class=""><br class=""></div><div class="">I hope that helps to make things a little more clear.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 29, 2015, at 19:44, Benjamin Greenman <<a href="mailto:blg59@cornell.edu" class="">blg59@cornell.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">This has bothered me too, but I've realized that I was on the wrong track.<div class=""><br class=""></div><div class="">The string "a" and symbol 'b are not different types. A struct (Foo "a" 'b), or (list "a" 'b), is a homogeneous data structure of type (U String Symbol) just like Alexander said. This really upsets me -- I like the Hindley Milner world where the compiler warns me if I make a list [1, "two"] and forces me to wrap the int and string into a new datatype. But Typed Racket is not HM.</div><div class=""><br class=""></div><div class="">About the proposal, I'm confused about what the syntax in Section 2.1 should do -- what is a "first class member of Typed Racket's type system"?</div><div class="">- Should an A only be a base type like String or Symbol</div><div class="">- Do you mean to infer the type of the first thing put into the struct as the exact type for everything else?<br class=""></div><div class="">- Would "first class members" prevent me from filling a struct with members of (define-type (Option A) (U 'None (Some A))), where "Some" is a struct with one field?</div><div class=""><br class=""></div><div class="">I totally agree that "something needs fixing", but I'm not sure what.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jan 29, 2015 at 10:13 PM, Alexis King <span dir="ltr" class=""><<a href="mailto:lexi.lambda@gmail.com" target="_blank" class="">lexi.lambda@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Or <font face="Courier" class="">Any</font> for that matter. I know. The fact that it could be literally anything was sort of the point.</div><div class=""><div class="h5"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 29, 2015, at 19:10, Alexander D. Knauth <<a href="mailto:alexander@knauth.org" target="_blank" class="">alexander@knauth.org</a>> wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">Um, for this:</div><div class=""><table cellspacing="0" cellpadding="0" style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class=""><tbody style="margin:0px;padding:0px" class=""><tr style="margin:0px;padding:0px;white-space:inherit" class=""><td style="margin:0px;padding:0px;vertical-align:baseline;white-space:inherit" class=""><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">(</span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class=""><a href="http://docs.racket-lang.org/reference/module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" style="margin:0px;padding:0px;text-decoration:none;color:rgb(0,119,170);font-size:1rem" target="_blank" class="">module</a></span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">typed</span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">typed/racket/base</span></td></tr><tr style="margin:0px;padding:0px;white-space:inherit" class=""><td style="margin:0px;padding:0px;vertical-align:baseline;white-space:inherit" class=""><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">(</span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class=""><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29" style="margin:0px;padding:0px;text-decoration:none;color:rgb(0,119,170);font-size:1rem" target="_blank" class="">provide</a></span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">(</span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class=""><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-out%29%29" style="margin:0px;padding:0px;text-decoration:none;color:rgb(0,119,170);font-size:1rem" target="_blank" class="">struct-out</a></span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">Foo</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">)</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">)</span></td></tr><tr style="margin:0px;padding:0px;white-space:inherit" class=""><td style="margin:0px;padding:0px;vertical-align:baseline;white-space:inherit" class=""><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">(</span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class=""><a href="http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._struct%29%29" style="margin:0px;padding:0px;text-decoration:none;color:rgb(0,119,170);font-size:1rem" target="_blank" class="">struct</a></span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">[</span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">A</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">]</span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">Foo</span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">(</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">[</span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">x</span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class=""><a href="http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" style="margin:0px;padding:0px;text-decoration:none;color:rgb(0,119,170);font-size:1rem" target="_blank" class="">:</a></span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">A</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">]</span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">[</span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">y</span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class=""><a href="http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29" style="margin:0px;padding:0px;text-decoration:none;color:rgb(0,119,170);font-size:1rem" target="_blank" class="">:</a></span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:inherit;font-size:1rem" class="">A</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">]</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">)</span><span style="margin:0px;padding:0px;white-space:inherit;font-size:1rem" class=""> </span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">#:transparent</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">)</span><span style="margin:0px;padding:0px;white-space:inherit;color:rgb(132,60,36);font-size:1rem" class="">)</span></td></tr></tbody></table><div class=""><br class=""></div></div><div class=""><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;color:rgb(132,60,36);font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class="">(</span><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class="">Foo</span><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class=""> </span><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;color:rgb(34,139,34);font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class="">"a"</span><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class=""> </span><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;color:rgb(34,139,34);font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class="">'</span><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;color:rgb(34,139,34);font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class="">b</span><span style="margin:0px;padding:0px;font-family:'Source Code Pro',monospace;white-space:pre-wrap;color:rgb(132,60,36);font-size:15px;line-height:22px;background-color:rgb(255,255,255)" class="">)</span></div><div class="">Should be fine because Foo could be instantiated at the type (U String Symbol).</div><br class=""><div class=""><div class="">On Jan 29, 2015, at 9:25 PM, Alexis King <<a href="mailto:lexi.lambda@gmail.com" target="_blank" class="">lexi.lambda@gmail.com</a>> wrote:</div><br class=""><blockquote type="cite" class=""><div style="word-wrap:break-word" class="">I recently ran into a problem in which opaque types (types imported from untyped code) cannot by parameterized by Typed Racket. I initially encountered this problem in <a href="https://github.com/lexi-lambda/racket-2htdp-typed/issues/1" target="_blank" class="">my attempt to port 2htdp/image to TR</a>.<div class=""><br class=""></div><div class="">After some further consideration, I’m interested in adding support to make something like this possible, which would certainly have additional benefits beyond this specific use-case. I’ve outlined my proposal here:</div><div class=""><a href="http://lexi-lambda.github.io/racket-parametric-opaque-types/" target="_blank" class="">http://lexi-lambda.github.io/racket-parametric-opaque-types/</a></div><div class=""><br class=""></div><div class="">Any feedback, suggestions, or advice would be appreciated, especially from those who are familiar with Typed Racket’s internals.</div><div class=""><br class=""></div><div class="">Thank you,</div><div class="">Alexis</div></div>_________________________<br class=""> Racket Developers list:<br class=""> <a href="http://lists.racket-lang.org/dev" target="_blank" class="">http://lists.racket-lang.org/dev</a><br class=""></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></div><br class="">_________________________<br class="">
Racket Developers list:<br class="">
<a href="http://lists.racket-lang.org/dev" target="_blank" class="">http://lists.racket-lang.org/dev</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>