readme.rkt (545B)
1 #lang typed/racket 2 (require type-expander 3 typed/rackunit 4 (for-syntax racket/list)) 5 6 (define-type-expander (Repeat stx) 7 (syntax-case stx () 8 [(_ t n) 9 #`(List #,@(map (λ (x) #'t) 10 (range (syntax->datum #'n))))])) 11 12 (: five-strings (→ String (Repeat String 5))) 13 (define (five-strings x) 14 (list x "a" "b" "c" "d")) 15 16 (check-equal? (five-strings "hello") 17 '("hello" "a" "b" "c" "d")) 18 19 (check-equal? (ann (five-strings "moon") (Repeat String 5)) 20 '("moon" "a" "b" "c" "d"))