Simple enough. This works:

#lang racket

(define (make-me-a-struct)
  (struct foo ())

(make-me-a-struct) ; => #<foo>

This does not:

#lang typed/racket

(define (make-me-a-struct)
  (struct foo ())
  (foo)) ; error: cannot apply a function with unknown arity


This problem makes sense. Type declarations seem to be a module-wide construct, 
so a type that should be scoped to a single function doesn’t work. I’m running 
into this issue when trying to create an executable struct using 
define-struct/exec from within a macro, which doesn’t work due to this 
particular problem.

I can work around this in a variety of ways—I can extract this into an untyped 
module and use require/typed, I can use vectors to “fake” structs and provide 
an appropriate interface, etc. Still, I wonder if there are any plans to 
resolve this type of problem? Since it seems to be an issue with how TR handles 
types at its core, I’m not even sure how feasible it would be.
  Racket Developers list:

Reply via email to