[racket] Cannot share a require/typed #:struct

From: Benjamin Greenman (blg59 at cornell.edu)
Date: Fri Feb 6 00:10:34 EST 2015

I've got three modules:
- One untyped module defines some structs
- One typed module defines some helper functions
- One typed module does some interesting things

I've also got a problem: I cannot share imported untyped structs between
the typed modules.

The problem goes away if I linearize the module dependencies, but I'd
prefer not to do that -- the situation I have in real life uses two
orthogonal modules of helper functions (so the overall inheritance graph is
a diamond).

Here's the minimal example. Can we at least make the error message more

#lang racket/base

(module data-defn racket/base
  (provide (struct-out foo))
  (struct foo ()))

(module utils typed/racket/base
  (provide foo->string)
  (require/typed (submod ".." data-defn) [#:struct foo ()])
  (: foo->string (-> foo String))
  (define (foo->string f) "foo"))

(module main typed/racket/base
  (require/typed (submod ".." data-defn) [#:struct foo ()])
  (require (submod ".." utils))
  (: main (-> Void))
  (define (main)
    (displayln (foo->string (foo)))))

;; Type Checker: type mismatch
;;  expected: foo
;;  given: foo
;;  in: (foo)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150206/1bac5dca/attachment-0001.html>

Posted on the users mailing list.