[racket] Typed Racket Binding For Plot

From: Neil Toronto (neil.toronto at gmail.com)
Date: Mon Oct 29 00:31:56 EDT 2012

On 10/27/2012 11:57 AM, Ray Racine wrote:
> Racket Committers,
>
> Noticed in the RacketCon that it was mentioned that there were nothing
> to lift the plot collection into TR.  Awhile back I did do a run at a
> fairly comprehensive TRing of the Plot collection.  All the basic things
> (basic plots etc) I attempted worked just fine.  While  I haven't used
> plot since, it currently builds without error against the current Racket
> Git Master.
>
> https://github.com/RayRacine/racket/tree/tr-plot/collects/typed/plot
>
> In general, I'd like to think that most of the heavy lifting is out of
> the way  in the sense of all the inane typing, but may require some polish.
>
> With the new release over, I'd like to start getting it merged into
> Racket.  Next steps???

Ah, I should have replied to this email before, not the other one. Well, 
I'm catching up.

I think the next step is to wait for me to be free to work on it.

IIRC, there were two issues with TR-ing plot:

  1. Typing functions that take optional arguments *and* keyword
     arguments.

  2. Mutable data types in input.

#1 is fixed *enough* now to put an actual TR face on plot without making 
users write a bunch of `#f' in every function application. The issue 
would be writing all the huge `case->' types. Not fun. TR needs a nicer 
way to specify optional arguments---maybe something corresponding to a 
`->*' contract.

Example of #2 is `points', which takes a (Listof (Vectorof Real)) IIRC. 
The problem is that you can't send a (Listof (Vectorof Integer)) to a 
function that accepts just that type, because vectors are mutable and 
could be used as a communication channel. (Plot won't mutate them into 
reals, but TR can't know that.) Fixing this requires either waiting for 
possibly research-level changes to TR, or changing plot's API.

I wouldn't mind changing the API; it would be nice to have things like 
`points' accept sequences anyway. I haven't put much thought into what 
would be in the sequences, though.

So I suppose that would be a nice next step. What's an appropriate type 
for pairs/triplets/tuples of numbers? Should we let it accept 
(Sequenceof (U (Listof Real) (Vectorof Real)))? (Would that subtype 
nicely?) Sequences of sequences?

Neil ⊥


Posted on the users mailing list.