macrotypes-nonstx
define-expand-check-relation
ec
er
define-typed-syntax
8.12

macrotypes-nonstx🔗ℹ

 (require macrotypes-nonstx/expand-check-sugar)
  package: macrotypes-nonstx

syntax

(define-expand-check-relation name
  [in-parameter ... -> out-parameter ...]
  call-syntax
  input-syntax
  output-syntax
  #:in-stx in-parameter
  #:out-stx out-parameter
  #:stop-ids stop-ids-expr
  #:bad-output bad-output-expr)
 
call-syntax = [call-elem ...]
     
input-syntax = [input-elem ...]
     
output-syntax = [output-elem ...]
     
call-elem = in-parameter
  | out-parameter
  | literal-id
     
input-elem = in-parameter
  | literal-id
     
output-elem = out-parameter
  | literal-id
Defines name as an expand-check relation, which can be thought of as a type-check relation that checks a form by expanding it.

To expand-check a form using it, use:

(ec call-elem ...)

To define a macro that can be expand-checked by it, use:

(define-typed-syntax macro-name
  ....
  [name
   [input-elem ...]
   premise ...
   (er name output-elem ...)]
  ....)

syntax

(ec call-elem ...)

 
call-elem = in-argument-expr
  | out-argument-pat
  | literal-id
ec stands for "expand-check".

Calls the expand-check relation defined by the call-elems. The in-argument-exprs are expression positions while the out-argument-pats are match patterns.

syntax

(er ec-name output-elem ...)

 
output-elem = out-argument-expr
  | literal-id
er stands for "expansion-result".

Combines the outputs of the expand-check relation ec-name into one value that can be returned from a macro. This is typically used as the result of a macro that uses define-typed-syntax:

(define-typed-syntax macro-name
  ....
  [ec-name
   [input-elem ...]
   premise ...
   (er ec-name output-elem ...)]
  ....)

syntax

(define-typed-syntax name clause ...)

 
clause = 
[ec-name
 [input-elem ...]
 premise ...
 (er ec-name output-elem ...)]
Defines name as a macro that can be typechecked by any of the ec-name expand-check relations from the clauses.