www

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

rackunit-kindchecking.rkt (877B)


      1 #lang racket/base
      2 (require (for-syntax rackunit syntax/srcloc) rackunit macrotypes/typecheck
      3          (only-in "../fomega2.rkt" current-kind-eval kindcheck?))
      4 (provide check-kind)
      5 
      6 ;; Note: this file is separate from macrotypes/examples/test/rackunit-kindcheck
      7 ;; because each one uses different defs of current-kind-eval and kindcheck?
      8 (define-syntax (check-kind stx)
      9   (syntax-parse stx #:datum-literals (⇒ ->)
     10     [(_ τ tag:id k-expected)
     11      #:with k (detach (expand/df #'(add-expected τ k-expected))
     12                       (stx->datum #'tag))
     13      #:fail-unless (kindcheck? #'k ((current-kind-eval) #'k-expected))
     14                    (format
     15                     "Type ~a [loc ~a:~a] has kind ~a, expected ~a"
     16                     (syntax->datum #'τ) (syntax-line #'τ) (syntax-column #'τ)
     17                     (type->str #'k) (type->str #'k-expected))
     18      #'(void)]))