How to avoid cycle loading in Typed Racket

69 Views Asked by At

consider a common situation, a.rkt

#lang typed/racket
(require "b.rkt")
(struct A ([a-b : B]))
(provide (struct-out A))

b.rkt

#lang typed/racket
(require "a.rkt")
(struct B ([b-a : A]))

(provide (struct-out B))

it will crush when racket a.rkt because cycle loading,but we just require b.rkt for type checking, as in python it would solved by

if typing.TYPE_CHECKING:
    import B

Is there any similar solution in typed racket like python?Or just types that contains each other must written in one file because limitation?

Two types in different typed racket module could reference to each other

0

There are 0 best solutions below