(module proof-commands mzscheme
(require (lib "contract.ss")
(lib "plt-match.ss")
(planet "combinators.ss" ("cce" "combinators.plt" 1 4))
(planet "contract-utils.ss" ("cobbe" "contract-utils.plt" 3 0)))
(provide/contract
[proof-command? predicate/c]
[expr-command? predicate/c]
[event-command? predicate/c]
[module-command? predicate/c]
[make-expr-command (-> syntax? (eta expr-command?))]
[make-event-command (-> syntax? (eta event-command?))]
[make-module-command (-> syntax? (listof syntax?) (eta module-command?))]
[expr-command-term (-> (eta expr-command?) syntax?)]
[event-command-term (-> (eta event-command?) syntax?)]
[module-command-outer (-> (eta module-command?) syntax?)]
[module-command-inner (-> (eta module-command?) (listof syntax?))]
[proof-command->sexp (-> (eta proof-command?) sexp/c)])
(define (expr-command? v)
(match v
[(list 'expr (? syntax?)) #t]
[_ #f]))
(define (event-command? v)
(match v
[(list 'event (? syntax?)) #t]
[_ #f]))
(define (module-command? v)
(match v
[(list 'module (? syntax?) (list (? syntax?) ...)) #t]
[_ #f]))
(define proof-command?
(disjoin expr-command? event-command? module-command?))
(define (make-expr-command expr)
(list 'expr expr))
(define (make-event-command event)
(list 'event event))
(define (make-module-command source event-list)
(list 'module source event-list))
(define expr-command-term cadr)
(define event-command-term cadr)
(define module-command-outer cadr)
(define module-command-inner caddr)
(define (deep-syntax->datum v)
(cond
[(syntax? v) (syntax-object->datum v)]
[(pair? v) (cons (deep-syntax->datum (car v))
(deep-syntax->datum (cdr v)))]
[else v]))
(define proof-command->sexp deep-syntax->datum)
)