Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-07 Thread Neil Toronto
I think this specific case covers pretty much every abstract data type written in Typed Racket, including all those exported by PFDS and math/array. (Well, the RAList type in PFDS would have to wrap its lists of roots in a struct to get great performance in untyped Racket instead of just good

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Sam Tobin-Hochstadt
On Sat, Jan 5, 2013 at 6:55 PM, Neil Toronto neil.toro...@gmail.com wrote: What if RAList could be exported as a polymorphic, opaque type? It seems the contract system could then exploit the fact that an RAList is always well-typed. What would it take? Tagging structs? A special chaperone?

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Robby Findler
What if you added an extra field to immutable values (ie all TR structs would have this hidden field) such that, when they passed across a boundary, the field got mutated to say what type it passed at. Then, when the value passed back into TR, TR could check to see if has this secret field and

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Sam Tobin-Hochstadt
On Sun, Jan 6, 2013 at 2:55 PM, Robby Findler ro...@eecs.northwestern.edu wrote: What if you added an extra field to immutable values (ie all TR structs would have this hidden field) such that, when they passed across a boundary, the field got mutated to say what type it passed at. Then, when

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Sam Tobin-Hochstadt
On Sun, Jan 6, 2013 at 3:13 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I wouldn't say you'd do it for cons cells (they are special in the runtime). This is for structs that are declared in TR. You would add the field everywhere (or places where the programmer asks only). Right, I

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Robby Findler
On Sun, Jan 6, 2013 at 2:18 PM, Sam Tobin-Hochstadt sa...@ccs.neu.eduwrote: The boundaries have the information; that's how the contracts got inserted in the first place. No, the contracts are parametric contracts using `parametric-/c`, and thus don't have any information about the types

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Robby Findler
Oh-- I think you're right that the type parameter can matter (it could go over to R as an Integer list and come back as a Boolean list or something). Robby On Sun, Jan 6, 2013 at 4:08 PM, Sam Tobin-Hochstadt sa...@ccs.neu.eduwrote: Sorry, that was very silly of me. That isn't what's

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Sam Tobin-Hochstadt
Right -- if we (the typed code) are picking the instantiation, then we have to check structurally, to make sure that it's really got integers everywhere. But if it's a plain type parameter, then the untyped side gets to pick it, and WLOG they could pick `Any`, meaning that there's no wrong values

Re: [racket-dev] Motivation for polymorphic opaque types

2013-01-06 Thread Robby Findler
Oh, I see. Yes, even better. Robby On Sun, Jan 6, 2013 at 4:36 PM, Sam Tobin-Hochstadt sa...@ccs.neu.eduwrote: Right -- if we (the typed code) are picking the instantiation, then we have to check structurally, to make sure that it's really got integers everywhere. But if it's a plain

[racket-dev] Motivation for polymorphic opaque types

2013-01-05 Thread Neil Toronto
I've implemented Okasaki's purely functional, random-access lists in Typed Racket. They perform well there. I thought I'd see how they would do crossing the contract barrier, so I ported my benchmarks to Racket. Here's what I get doing `list-ref', passing each index of 1-to-10-element lists