modular/interface.ss
#lang scheme/base

(require (for-syntax scheme/base
                     "static-rep.ss"
                     "syntax-meta.ss")

         scheme/stxparam
         "keywords.ss"
         "dynamic-rep.ss")

(provide interface-macro)

(define-for-syntax (spec->static stx)
  (syntax-case stx (sig con)
    [(sig f (x ...)) (syntax/loc stx (make-sig/static #'f (list #'x ...)))]
    [(con f e options ...)
     (syntax/loc stx (make-con/static #'f #'e #'(options ...)))]
    [(include i)
     (syntax/loc stx (make-include/static (syntax->meta #'i)))]))

(define-for-syntax (expand-interface stx)
  (syntax-case stx ()
    [(_ name spec ...)
     (with-syntax ([(spec/static ...)
                    (map spec->static (syntax->list #'(spec ...)))])
       (syntax/loc stx
         (define-syntax name
           (make-syntax-meta
            (make-interface/static #'name (list spec/static ...))
            (expand-keyword "cannot be used as an expression")))))]))

(define-syntax interface-macro expand-interface)