How can I access the types of a structure's members in the typed/racket language? The function extract-struct-info does give a list of field accessors but not their types.
(require (for-syntax racket/struct-info
syntax/parse))
(define-syntax (display-struct-info stx)
(syntax-parse stx
[(display-struct-info name:id)
(display (extract-struct-info (syntax-local-value #'name)))
#'(list)]))
(struct: s ([a : Number] [b : String]))
(display-struct-info s)
Outputs:
(.#<syntax:12:9 struct:s> .#<syntax make-s> .#<syntax:12:9 s?> (.#<syntax:12:9 s-b> .#<syntax:12:9 s-a>) (#f #f) #t)'()
More generally, how can I access typed/racket's types, like getting the list of types in a union type (U Number String 'foo 'bar), or seeing the arguments to a polymorphic type?
I am interested only in macro-expansion-time access, not run-time access.
Related: Get the type information in macros (same question for Common Lisp)
Aucun commentaire:
Enregistrer un commentaire