www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

bench001.rkt (763B)


      1 #lang type-expander/lang
      2 (require (for-syntax racket
      3                      phc-toolkit))
      4 
      5 (struct Or ())
      6 (define-type-expander (Invariants stx)
      7   (syntax-case stx ()
      8     [(_ invᵢ …)
      9      #'(→ (U Or (→ invᵢ Void) …) Void)
     10      #;#'(→ (→ (∩ invᵢ …) Void) Void)]))
     11 
     12 
     13 
     14 (define-syntax (foo stx)
     15   (syntax-case stx ()
     16     [(_ T nb)
     17      #`(define-type T
     18          (Invariants
     19           #,@(map (λ (x) #`(List 'a 'b 'c 'd 'e 'f 'g 'h 'i 'j 'k #,x 'm 'n))
     20                   (range (syntax-e #'nb)))))]))
     21 (foo T0 600)
     22 (foo T1 550)
     23 
     24 (define f0 : T0 (λ (x) (void)))
     25 
     26 (define-syntax (repeat stx)
     27   (syntax-case stx ()
     28     [(_ n body)
     29      #`(begin #,@(map (const #'body)
     30                       (range (syntax-e #'n))))]))
     31 (repeat 100
     32         (ann f0 T1))