Sure, I'll probably sketch out a goodly chunk of Plot into TR this weekend and will do that modification.<div><br></div><div>My little POC of TRing the Hist* procedures ended translating pretty well.</div><div><br></div>
<div><a href="https://gist.github.com/3317104">https://gist.github.com/3317104</a></div><div><br></div><div>The only "bump" I'm still seeing is in attempting to leverage Snip% out of typed/mred/mred.</div><div>
<br></div><div>When I try and type </div><div>(plot (Renderer-Tree ... stuff ... -> (U Snip% Void))</div><div><br></div><div>running (test3) fails.</div><div><br></div><div>What I have now just stubs def-type Image-Snip% with Any, which isn't that bad at all.</div>
<div><br></div><div>Is it because TR is currently invariant with Classes or did I tickle another bug here? Image-Snip% is a sub-type (class) of Snip%.</div><div><br></div><div>Say if typed/mred/mred explicitly proved a typed Image-Snip% would everything work?</div>
<div><br></div><div>Ray</div><div><br></div><div><br><div class="gmail_quote">On Fri, Aug 10, 2012 at 3:00 PM, Neil Toronto <span dir="ltr"><<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 08/10/2012 11:54 AM, Sam Tobin-Hochstadt wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, Aug 10, 2012 at 1:38 PM, Ray Racine <<a href="mailto:ray.racine@gmail.com" target="_blank">ray.racine@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Here <a href="https://gist.github.com/3315984" target="_blank">https://gist.github.com/<u></u>3315984</a><br>
<br>
The first (test1) works fine. Note it uses a KW arg.<br>
<br>
However, (test2) fails. I thought it was the complexity of the first arg<br>
that I was getting wrong. But when the KW #:label is commented out it works<br>
fine.<br>
</blockquote>
<br>
What's happening here is that vectors don't subtype the way lists do,<br>
so (Vector Symbol Flonum) isn't an appropriate value when you need a<br>
(Vector Any (U Real False Interval)). This isn't a problem when you<br>
don't have the keyword argument, because Typed Racket can figure out<br>
the needed types from the type of `discrete-histogram`, and so gives<br>
the vector literals appropriate types. However, TR doesn't currently<br>
manage to propagate this information when looking at keyworded<br>
applications, which are much more complex when expanded. Thus the<br>
behavior you're seeing.<br>
<br>
If we give TR a little help here, then this works:<br>
<br>
(define: lst : (Listof (Vector Any (U Real False Interval)))<br>
(list #(A 1.0) #(B 2.0) #(B 3.0) (vector 'C (ivl 0.5 1.5))))<br>
<br>
(define (test2)<br>
(plot (discrete-histogram lst #:label "Hello")))<br>
<br>
One way that `plot` could make this easier would be to support lists<br>
in addition to vectors for histogram data.<br>
</blockquote>
<br></div></div>
That wouldn't be hard to change. The contract and function are both defined in the file "plot/plot2d/rectangle.rkt". You want to take a crack at it, Ray? :)<br>
<br>
You should only have to change the contract of `cat-vals' in `discrete-histogram' (to se `or/c'), and change the match pattern that destructures it to (list (or (vector cats ys) (list cats ys)) ...).<span class="HOEnZb"><font color="#888888"><br>
<br>
Neil ⊥</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a><br>
</div></div></blockquote></div><br></div>