Bingo. Thanks.<br><br><div class="gmail_quote">On Fri, Aug 10, 2012 at 3:43 PM, Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@ccs.neu.edu" target="_blank">samth@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Fri, Aug 10, 2012 at 3:34 PM, Ray Racine <<a href="mailto:ray.racine@gmail.com">ray.racine@gmail.com</a>> wrote:<br>
> Sure, I'll probably sketch out a goodly chunk of Plot into TR this weekend<br>
> and will do that modification.<br>
><br>
> My little POC of TRing the Hist* procedures ended translating pretty well.<br>
><br>
> <a href="https://gist.github.com/3317104" target="_blank">https://gist.github.com/3317104</a><br>
><br>
> The only "bump" I'm still seeing is in attempting to leverage Snip% out of<br>
> typed/mred/mred.<br>
><br>
> When I try and type<br>
> (plot (Renderer-Tree ... stuff ... -> (U Snip% Void))<br>
><br>
> running (test3) fails.<br>
<br>
</div>It would be easier for me to tell if you include the error message.<br>
But probably the issue is that you need (Instanceof Snip%), not just<br>
Snip%, which is the type of a *class*, not an object.<br>
<div class="HOEnZb"><div class="h5"><br>
> What I have now just stubs def-type Image-Snip% with Any, which isn't that<br>
> bad at all.<br>
><br>
> Is it because TR is currently invariant with Classes or did I tickle another<br>
> bug here? Image-Snip% is a sub-type (class) of Snip%.<br>
><br>
><br>
> Say if typed/mred/mred explicitly proved a typed Image-Snip% would<br>
> everything work?<br>
><br>
> Ray<br>
><br>
><br>
> On Fri, Aug 10, 2012 at 3:00 PM, Neil Toronto <<a href="mailto:neil.toronto@gmail.com">neil.toronto@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On 08/10/2012 11:54 AM, Sam Tobin-Hochstadt wrote:<br>
>>><br>
>>> On Fri, Aug 10, 2012 at 1:38 PM, Ray Racine <<a href="mailto:ray.racine@gmail.com">ray.racine@gmail.com</a>> wrote:<br>
>>>><br>
>>>> Here <a href="https://gist.github.com/3315984" target="_blank">https://gist.github.com/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<br>
>>>> arg<br>
>>>> that I was getting wrong. But when the KW #:label is commented out it<br>
>>>> works<br>
>>>> fine.<br>
>>><br>
>>><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>
>><br>
>><br>
>> That wouldn't be hard to change. The contract and function are both<br>
>> defined in the file "plot/plot2d/rectangle.rkt". You want to take a crack at<br>
>> it, Ray? :)<br>
>><br>
>> You should only have to change the contract of `cat-vals' in<br>
>> `discrete-histogram' (to se `or/c'), and change the match pattern that<br>
>> destructures it to (list (or (vector cats ys) (list cats ys)) ...).<br>
>><br>
>> Neil ⊥<br>
>><br>
>><br>
>> ____________________<br>
>> Racket Users list:<br>
>> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
sam th<br>
<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br>
</font></span></blockquote></div><br>