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

From: Alexis King (lexi.lambda at gmail.com)
Date: Fri Feb 6 00:15:41 EST 2015

Why not create an intermediary module? Create a typed module, call it typed/data-defn, and use require/typed/provide to import the struct and provide it. Then just require that module for all other modules that need to use that struct in a typed context.

> On Feb 5, 2015, at 21:10, Benjamin Greenman <blg59 at cornell.edu> wrote:
> 
> 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 helpful?
> 
> #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)
> 
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150205/f0722ce9/attachment.html>

Posted on the users mailing list.