On Mon, Apr 2, 2018 at 10:38 PM, Philip McGrath
<phi...@philipmcgrath.com> wrote:
> While experimenting with porting an typed program to Typed Racket, I
> encountered a few surprises. Some of these seem like they might be bugs,
> others missing features, and several probably are misunderstandings on my
> part.
> 1. struct subtyping doesn't work with #:type-name
> The following program fails to typecheck with the error "Type Checker:
> parent type not a valid structure name: animal":
> #lang typed/racket
> (struct animal ()
>   #:type-name Animal
>   #:transparent)
> (struct dog animal ()
>   #:transparent)
> Trying to use `Animal` as the parent of `dog` doesn't work either, producing
> the expected error from `struct` that `Animal` is not bound to struct type
> information.

This is in some ways a weakness in the concept for `#:type-name`. The
`struct` form relies on the parent struct to both find the type and to
find the parent struct in the underlying `struct` macro. We could add
a `#:parent-type-name` option to use here, but then we'd have to
enforce that they go together in some way. I'm not sure what the best
design is here.

To work around this, try:

#lang typed/racket
(struct animal () #:transparent)
(struct dog animal () #:transparent)
(define-type Animal animal)


#lang typed/racket
(struct animal () #:transparent
  #:type-name Animal)
(define-type animal Animal #:omit-define-syntaxes)
(struct dog animal () #:transparent)

> 2. Problems with define-struct/exec

This looks like a bug, but I'm not immediately sure where. Can you
report this on GitHub?

> 3. parse-command-line doesn't support usage-help, help-labels, help-proc, or
> unknown-proc

These should be easy additions to the type here:

I'll look at it soon, but if you have time to try it out and submit a
PR, that would be wonderful.

> Thanks to all who have worked on and promoted Typed Racket! Really, it is
> remarkable how few surprises there are when adding types to an untyped
> program.

Glad you're enjoying it, and thanks for the bug reports.


You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to