> On Nov 13, 2017, at 3:25 PM, Stuart Hungerford <stuart.hungerf...@gmail.com> 
> wrote:
> Hi,
> I'm trying to create a Typed Racket function that compares to 2-vectors of 
> integers with an optional error term that defaults to 1:
> #lang typed/racket
> (define-type Reading (Vector Integer Integer))
> (: close? (->* (Reading Reading) (Integer) Boolean))
> (define/match (close? r1 r2 [err 1])
>   [((vector a b) (vector c d) e)
>     (and (= a (+ c e)) (= b (+ d e)))])
> In untyped Racket the function compiles and runs as I expected. In Typed 
> Racket the pattern-matched values all seem to have type "Any". 
> I think there's some interaction between Typed Racket's typing rules and the 
> define/match macro that I haven't understood properly? As a complete Racket 
> newb I may also be going about this the wrong way.  Any advice much 
> appreciated.

This seems to be a problem with define/match specifically, since define + 
match* works fine for this function:

(: close? (->* (Reading Reading) (Integer) Boolean))
(define (close? r1 r2 [err 1])
  (match* (r1 r2 err)
    [((vector a b) (vector c d) e)
     (and (= a (+ c e)) (= b (+ d e)))]))

Others: Does define/match do anything that would make Typed Racket see it 
differently from define + match*? It seems like define/match expands to define 
+ match*/derived anyway. The only thing that's different is which define it's 
expanding to. So is expanding to Racket's define instead of TR's causing the 

Alex Knauth

> Thanks,
> Stu

You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to