> On Jun 12, 2015, at 6:07 PM, Asumu Takikawa <as...@ccs.neu.edu> wrote:
> 
> On 2015-06-12 17:30:42 -0700, 'John Clements' via users-redirect wrote:
>> (define-type (HuffJsexpr T)
>>  (U T (HashTable Symbol HuffJsexpr)))
> 
> The variant that Alex mentioned should work.

Interesting… there *is* a problem, though; If I try to write a function with 
the type, say,

(All (T) ((HuffJsexpr T) -> number))

I get into trouble quickly trying to distinguish between the two variants, 
because of course the type T might be something confusing like (HashTable 
Symbol Symbol), so no test can distinguish between the two variants. 

Anyhow, no big deal, I can just make them dynamic checks.

Okay, I shouldn’t change topics, but while I’ve got you (guys): it looks like 
(module+ test …) now works in TR, but not when there are imported bindings… 
suppose I have foo.rkt:

#lang typed/racket

(provide [struct-out Z])

(define-struct Z ([a : Number]))

… and then try to import it in a test+:

#lang typed/racket

(require "foo.rkt")

(Z 3)

(module+ test
  (Z 3))

this leads to this error message:

Type Checker: missing type for identifier;
 consider using `require/typed' to import it
  identifier: make-Z
  from module: (submod foo.rkt #%contract-defs-reference .. #%contract-defs) 
in: make-Z

I tried various require/typed combinations, but only managed to get an error on 
`make-Z1`, which doesn’t sound like forward progress.

John

> 
> I think the only restrictions on recursive types that TR enforces are that it
> has to be (A) productive, in that there's a real type constructor in the
> recursive body, and (B) it can't be polymorphic recursive.
> 
> (A) implies something like (Rec X (U Integer X)) isn't allowed. U doesn't
> count as a type constructor for this purpose.
> 
> (B) implies you can't have a type definition like:
> 
>  (define-type (MyType T) (U Integer (MyType (Listof T))))
> 
> where the instantiated type changes.
> 
> Cheers,
> Asumu

-- 
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