www

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

rackunit-kindchecking.rkt (721B)


      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 (define-syntax (check-kind stx)
      7   (syntax-parse stx #:datum-literals (⇒ ->)
      8     [(_ τ tag:id k-expected)
      9      #:with k (detach (expand/df #'(add-expected τ k-expected))
     10                       (stx->datum #'tag))
     11      #:fail-unless (kindcheck? #'k ((current-kind-eval) #'k-expected))
     12                    (format
     13                     "Type ~a [loc ~a:~a] has kind ~a, expected ~a"
     14                     (syntax->datum #'τ) (syntax-line #'τ) (syntax-column #'τ)
     15                     (type->str #'k) (type->str #'k-expected))
     16      #'(void)]))