I don't think you're doing anything wrong, and I expect that this case [1] needs a bit of generalization to handle polymorphic structs.
[1] https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/typecheck/tc-app/tc-app-hetero.rkt#L82-L83 Sam On Thu, Feb 12, 2015 at 8:21 PM, Antonio Menezes Leitao <antonio.menezes.lei...@ist.utl.pt> wrote: > Hi, > > The following example works in Typed Racket: > > (struct foo > ([c : Float] > [f : (foo -> Float)])) > > (define (test [f : foo]) : Float > ((foo-f f) f)) > > (test > (foo 1.0 > (lambda ([x : foo]) : Float > (match x ((foo c _) c))))) > > (struct bar foo > ([i : Float])) > > (test > (bar 1.0 > (lambda ([x : foo]) : Float > (match x > ((bar c _ i) (+ c i)))) > 1.0)) > > > Unfortunately, I couldn't make foo polymorphic: > > (struct (R) foo > ([c : R] > [f : ((foo R) -> R)])) > > (define (test [f : (foo Float)]) : Float > ((foo-f f) f)) > > (test > (foo 1.0 > (lambda ([x : (foo Float)]) : Float > (match x > ((foo c _) c))))) > > (struct (R) bar foo > ([i : Float])) > > (test > (bar 1.0 > (lambda ([x : (foo Float)]) : Float > (match x > ((bar c _ i) (+ c i)))) > 1.0)) > > The problem is in the match in the last expression, which shows three type > errors: > > Type Checker: cannot apply a function with unknown arity; function > `unsafe-struct-ref' has type Procedure which cannot be applied in: (match x > ((bar c _ i) (+ c i))) > #(364 41) > > Can someone tell me what I'm doing wrong here? > > Thanks, > António. > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > ____________________ Racket Users list: http://lists.racket-lang.org/users