[racket] Typed Racket reactions on developing polymorphic typed array library, and questions

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Mon Aug 23 18:29:50 EDT 2010

On Mon, Aug 23, 2010 at 6:12 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
> Sam Tobin-Hochstadt wrote:
>> In general, `define:' and `let:' require return types since they
>> define (potentially) recursive functions, and therefore a type needs
>> to be given to the function, which wouldn't be known without
>> typechecking the body, which could reference the function.  This is
>> also why `for/list:' needs a return type annotation - it's expanding
>> into a `let loop' underneath.
> Ahhh, okay. My loops destructively update a newly allocated vector (or other
> array model) and iterate over one or more Nonnegative-Fixnum indexes. The
> loops they expand to always have type Nonnegative-Fixnum or similar.

In that case, you can probably insert the annotation yourself in a
macro, if it's generated (such as with your `forall' macros).  In
other cases, I don't have much help to offer.

>>>  - Polymorphic structs being proper subtypes of their parent structs
>>> would
>>> be really nice. As it is, I can't figure out how to cleanly have a
>>> "(vector-array T)" subtype of "(array T)" that gives private array
>>> functions
>>> access to the vector backing an array. If I had that, I could collapse
>>> compositions of certain array ops at runtime and remove some duplicate
>>> bounds checks.
>> I'm not sure exactly what you mean here.  Can you give an example?
> Yep. Here's the array type:

[helpful example elided]

Hmm.  I see why this doesn't work currently.  A workaround would be to
use unions rather than struct subtyping, here, but I'll try to make
this work.  If you could submit a bug report, that would help.
sam th
samth at ccs.neu.edu

Posted on the users mailing list.