lang/encapsulate.ss
(module encapsulate mzscheme

  ;; Does not work for include-book, leaving out for now.

  #|
  (require-for-syntax "../lang/proof/proof-syntax.ss")
  (require (lib "stxparam.ss")
           "defun.ss")

  (provide local encapsulate)

  (define-syntax (local stx)
    (syntax-case stx ()
      [(l term) (make-event stx #'term)]))

  (define-syntax (strip-local stx)
    (syntax-case stx (local)
      [(sl (local term)) (syntax/loc stx (begin))]
      [(sl term) #'term]))

  (define-syntax (encapsulate stx)
    (syntax-case stx ()
      [(e ((f (arg ...) result) ...) body ...)
       (make-event
        stx
        (quasisyntax/loc stx
          (begin
            (let* ()
              body ...
              (void (lambda (arg ...) (f arg ...)) ...))
            (defstub f (arg ...) result) ...
            (strip-local body) ...)))]))
  |#

  )