typed-syntax-predicate.rkt (1510B)
1 #lang typed/racket 2 3 (provide isexp? 4 CoreSexp) 5 6 (module unsafe racket 7 (provide isexp?) 8 9 (define isexp/c 10 (flat-rec-contract isexp 11 (or/c boolean? 12 char? 13 number? 14 keyword? 15 null? 16 (and/c string? immutable?) 17 symbol? 18 (box/c isexp #:immutable #t) 19 (cons/c isexp isexp) 20 (vectorof isexp #:immutable #t)))) 21 22 (define sexp/c 23 (recursive-contract 24 (or/c boolean? 25 char? 26 number? 27 keyword? 28 null? 29 string? 30 symbol? 31 (box/c sexp/c) 32 (cons/c sexp/c sexp/c) 33 (vectorof sexp/c)))) 34 35 (define isexp? 36 (flat-contract-predicate isexp/c))) 37 38 (define-type CoreSexp (Rec core-sexp 39 (U Boolean 40 Char 41 Number 42 Keyword 43 Null 44 String 45 Symbol 46 #|(Boxof sexp)|# 47 (Pairof core-sexp core-sexp) 48 #|(Vectorof sexp)|#))) 49 50 (require typed/racket/unsafe) 51 (unsafe-require/typed 'unsafe 52 [isexp? (→ Any Boolean : #:+ Sexp #:- (! CoreSexp))])