[racket] Port of Plot collection to TR
I think this should do it:
(define-type (Listof* A) (Rec T (U A (Listof T))))
(define-type Renderer-Tree (Listof* (U renderer2d nonrenderer)))
Neil ⊥
On 08/09/2012 01:56 PM, Ray Racine wrote:
> I could try and and seed a few things out of plot into TR that I have an
> immediate need for. require/typed, optional args, opaque, typing Snips
> as Class ... I can handle.
>
> This one however ...
> Suggestions on how one would type the following?
>
> renderer-tree : (treeof (or/c renderer2d? nonrenderer?))
>
> On Thu, Aug 9, 2012 at 3:27 PM, Neil Toronto <neil.toronto at gmail.com
> <mailto:neil.toronto at gmail.com>> wrote:
>
> On 08/09/2012 12:52 PM, Ray Racine wrote:
>
> Noticed here
> http://www.ccs.neu.edu/home/__samth/adapt/Current_Status.__html
> <http://www.ccs.neu.edu/home/samth/adapt/Current_Status.html>
>
>
> I had no idea someone had been assigned. Cool!
>
>
> That the Plot collection still awaits porting to TR. Has any
> partial
> work been done, maybe languishing in a github repo somewhere,
> that can
> be leveraged?
>
>
> Are you volunteering? :)
>
> It's only possible now that TR has support for keyword arguments.
>
> There's one issue that could cause problems: some renderer-producing
> functions, like `points', accept lists of vectors as arguments. If
> the data argument to `points' had a nice, general type like
>
> (Listof (Vectorof Real Real))
>
> then applying `points' to
>
> '(#(0.0 1.0) #(1.0 2.2))
>
> wouldn't typecheck. The problem is that TR thinks `points' might
> change that 0.0 to 0, which would make the original argument type
> (Listof (Vector Float Float)) incorrect. It thinks Bad Things could
> happen. (Technically, a vector is "invariant".)
>
> I can think of two solutions right now:
>
> 1. Wait for a Const type constructor or similar.
>
> 2. Change the contract of `points' to accept lists of pairs,
> sequences or a specialized data type.
>
> I think the contract of `points' should be changed anyway, so users
> can send it any kind of sequence. Might as well make it
> current-TR-friendly at the same time.
>
> Neil ⊥
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/__users
> <http://lists.racket-lang.org/users>
>
>