[racket] Typed racket with serializable struct

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Fri Sep 6 17:42:21 EDT 2013

You've stumbled upon two different bugs here.

1. Submodules and Typed Racket interact badly -- this is a bug in the
internals of Racket, but won't be fixed in the near future.  The
workaround, as you discovered, is to use a separate files.
2. `struct-out` and `struct:` interact badly.  This is a bug in Typed
Racket, and it might be fixed by some work currently in progress by
Eric Dobson.  The workaround, as you also discovered, is to explicitly
write out the `provide`.

Sam

On Fri, Sep 6, 2013 at 4:17 PM, antoine <antoine597 at gmail.com> wrote:
> Hello,
>
> I would like to use a 'serialize-struct' in typed/racket.  It seems there is
> no
> 'serialize-struct:' built in typed/racket.
>
> So i have decided to put the struct into a specific submodule and
> require/type
> the structs.
>
> ;;----test.rkt----
> #lang typed/racket
>
> (module data-structs racket
>   (require racket/serialize)
>
>   (serializable-struct ArrayType (expr) #:transparent)
>
> (provide struct:ArrayType ArrayType? ArrayType ArrayType-expr))
>
> (require/typed 'data-structs
>           [#:struct ArrayType
>             ([expr : Integer])])
> ;;----test.rkt----
>
> I get this errors which i can't understand:
>
> link: module mismatch;
>  possibly, bytecode file needs re-compile because dependencies changed
>   importing module: 'phpdoc-struct
>   exporting module: 'phpdoc-struct
>   exporting phase level: 0
>   internal explanation: variable not provided (directly or indirectly)
>   at: ArrayType2
>   in: ArrayType.17
>
> Note that if i use two file it works.
> Note if i use (provide (struct-out ArrayType)) i get the following error:
>
> phpdoc-struct.rkt:6:23: module: provided identifier not defined or imported
> for phase 0
>   at: ArrayType
>   in: (#%module-begin (#%require racket/serialize) (define-values
> (struct:ArrayType ArrayType1 ArrayType? ArrayType-expr) (let-values
> (((struct: make- ? -ref -set!) (letrec-syntaxes+values
> (((struct-field-index12) (convert-renamer (lambda (stx) (syntax-case s...
>
> I have no idea of what happen?
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.