typed-racket
typed-racket copied to clipboard
Unnecessary Chaperones?
I mentioned on the mailing list that Typed Racket adds chaperones that seem unnecessary. I only found two examples, but if I find more I will update this item.
Example 1
Tested with 8.0.0.11--2021-03-15(c0cfd32/a) [cs]
#lang racket
(module m typed/racket
(provide f)
(: f (-> Any Any))
(define (f x) x))
(require 'm)
(struct s (a b) #:transparent #:authentic)
(f (s 1 2))
Example 2
Tested with 8.0.0.11--2021-03-15(c0cfd32/a) [cs].
#lang racket
(module m typed/racket
(provide (all-defined-out))
(require/typed racket [prop:authentic Struct-Type-Property])
(struct s ([a : Integer]) #:transparent
#:property prop:authentic #t)
(: go (-> (-> Any Any) Void))
(define (go f)
(println (f (s 1)))))
(require 'm)
(go identity)
I was surprised that changing the type of go to (: go (-> (-> s Any) Void)) causes the program to work, with no chaperone being generated.