I was trying to write an AST using something like this:
(define-type Exp (U Const Op ...))
(struct Const (...) #:prefab)
without prefab it is ok, but when I added prefab it takes more than a minute from clicking Run to getting a cursor in the interactions window. I tried typed/racket/optional but it is the same.
Does this look like a bug or is it normal because of the stuff that prefab adds?
Thanks. It looks like the compilation time is dominated by generating contracts for the functions you're providing. If you provide fewer structs compilation is much faster. (Obviously that's not good, but it might be a useful workaround for you.)
yeah, what I'm doing is removing the "#:prefab"s, so it compiles fast again, and I'll write a separate printer function when I need it. It was cool to have an auto-magical serializer, but it's not a problem.
The problem is that contracts for prefabs have to check the field types, rather than just relying on the predicates. Since anyone can construct an instance of those prefab types, the contracts have to walk the entire value to check that it matches the type.
I think what's going on is that Typed Racket effectively inlines the entire types into each contract so the generated code (and the runtime to generate that code) is very large. Typed Racket could definitely do better here, but the relevant code is pretty tricky.