Re: [racket-users] Interaction of Typed Racket with define/match?

2017-11-17 Thread Ben Greenman
> 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 problem?

I think so. It seems like Typed Racket is ignoring the type annotation
and trying to infer a type for the function body.

Here's a github issue for this:
https://github.com/racket/typed-racket/issues/653

-- 
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.


Re: [racket-users] Interaction of Typed Racket with define/match?

2017-11-13 Thread Alex Knauth

> On Nov 13, 2017, at 3:25 PM, Stuart Hungerford  
> 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 
problem?

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.


[racket-users] Interaction of Typed Racket with define/match?

2017-11-13 Thread Stuart Hungerford
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.

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.