Instruction:
Generate a defmacro form that transforms code like this:
(iter
  nil
  nil)

Pattern to recognize: Macro call that should be transformed by ITER

Input:
(iter
  nil
  nil)

Output:
(defmacro iter (&body body &environment env)
  "Jonathan Amsterdam's powerful and extensible iteration facility,
providing multiple accumulation, generators, memory of previous
iterations, over 50 clauses to start with and a Lisp-like syntax.
Evaluate (iterate:display-iterate-clauses) for an overview of clauses"
  (let* ((*env* env)
	 (*result-var* (genvar 'result))
	 (*type-alist* nil)
	 (*declare-variables* *always-declare-variables*)
	 (*bindings* nil)
	 (*internal-variables* nil)
	 (*previous-vars-alist* nil)
	 (*declarations* nil)
	 (*loop-body-wrappers* nil)
	 (*accum-var-alist* nil)
	 (*shared-bindings-alist* nil)
	 (*top-level?* t)
	 (*binding-context?* nil)
	 (*temps* nil)
	 (*temps-in-use* nil)
	 (*driver-info-alist* nil)
	 (*loop-name* (if (symbolp (car body))
			  (car body)
			  (gensym "ITERATE")))
	 (*block-name* (if (symbolp (car body))
			   (pop body)
			   nil))
	 (*loop-top* (symbol-append 'loop-top- *block-name*))
	 (*loop-step* (symbol-append 'loop-step- *block-name*))
	 (*loop-end* (symbol-append 'loop-end- *block-name*))
	 (*loop-step-used?* nil)
	 (*loop-end-used?* nil))
    (process-top-level-decls body)
    (multiple-value-bind (body decls init-code steppers final-code final-prot)
	(walk-list body)
      (multiple-value-bind (init step)
	  (insert-previous-code)
	(augment init-code init)
	(augment steppers step))
      (prepend (default-driver-code) body)
      (let* ((it-bod `(block ,*loop-name*
			(tagbody
			  (progn ,.init-code)
			  ,*loop-top*
			  (progn ,.body)
			  ,.(if *loop-step-used?* (list *loop-step*))
			  (progn ,.steppers)
			  (go ,*loop-top*)
			  ,.(if *loop-end-used?* (list *loop-end*))
			  (progn ,.final-code))
			,(if (member *result-var* *bindings* :key #'car)
			   *result-var*
			   nil)))
	     (it-bod (if (eql *block-name* nil)
			 `(block nil ,it-bod)
			 it-bod)))
	(wrap-form *loop-body-wrappers*
		   `(let* ,(nreverse *bindings*)
		     ,.(if *declarations*
			   `((declare .,*declarations*)))
		     ,.decls
		     ,(if final-prot
			  `(unwind-protect ,it-bod .,final-prot)
			  it-bod)))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-hook-generic nil (progn))

Issue: Macro call that should be transformed by DEFINE-HOOK-GENERIC

Input: (define-hook-generic nil (progn))

Output:
(defmacro define-hook-generic (name gf-lambda-list &rest options)
  "utility to help with gf's with method combination by remembering the combination type

by default the combination type becomes the default qualifier for any newly defined hooks
this can be overriden by not using this and using defgeneric or supplying
the option :default-qualifier.

supplying `:hook-point t` will create a method qualified with the default-qualifier
so that the generic acts like an extensible hook point and will not signal
no-applicable-method error when no hooks have been defined.

See defhook"
  (let* ((combination-option (find :method-combination options :key #'car :test #'eql))
         (combination-type
          (cond ((null combination-option) 'progn)
                ((null (cadr combination-option)) :unqualified)
                ((eql 'standard (cadr combination-option)) :unqualified)
                (t (cadr combination-option))))
         (default-qualifier
          (let ((d (cadr (find :default-qualifier options :key #'car :test #'eql))))
            (if (null d) combination-type d)))
         (hook-point (find :hook-point options :key #'car)))

    (intern-hook-generic name combination-type default-qualifier)
    `(progn (intern-hook-generic ',name ',combination-type ',default-qualifier)
            (defgeneric ,name ,gf-lambda-list
              ,@ (remove-if (lambda (s) (or (eql s :method-combination)
                                            (eql s :default-qualifier)
                                            (eql s :hook-point)))
                            options :key #'car)
                 (:method-combination
                   ,(if (eql :unqualified combination-type) 'standard combination-type)))

            ,(when hook-point
               (remove :unqualified `(defmethod ,name ,default-qualifier ,gf-lambda-list)
                       :end 3)))))


Instruction:
Generate a defmacro form that transforms code like this:
(dynamic-relet nil)

Pattern to recognize: Macro call that should be transformed by DYNAMIC-RELET

Input: (dynamic-relet nil)

Output: (defmacro DYNAMIC-RELET ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-slots nil
    nil)

Problem: Macro call that should be transformed by WITH-SLOTS

Input:
(with-slots nil
    nil)

Output: (defmacro WITH-SLOTS ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(undef$method 'lol-gen::some-name)

Issue: Macro call that should be transformed by UNDEF$METHOD

Input: (undef$method 'lol-gen::some-name)

Output: (defmacro UNDEF$METHOD ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(define-parse-method nil
    (progn))

What needs to change: Macro call that should be transformed by DEFINE-PARSE-METHOD

Input:
(define-parse-method nil
    (progn))

Output:
(defmacro define-parse-method (name lambda-list &body body)
  "Define a type parser on NAME and lists whose CAR is NAME."
  (discard-docstring body)
  (warn-if-kw-or-belongs-to-cl name)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (find-type-parser ',name)
           (lambda ,lambda-list ,@body))
     ',name))


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-stemcell-infer-hook 'lol-gen::some-name)

Issue: Macro call that should be transformed by WITH-STEMCELL-INFER-HOOK

Input: (with-stemcell-infer-hook 'lol-gen::some-name)

Output:
(defmacro with-stemcell-infer-hook (func &body body)
  (let ((func-name (gensym "hook")))
    `(let* ((,func-name ,func)
            (*stemcell-infer-hook* ,func-name))
       ,@body)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-shadowed-custom-vars
  nil)

Problem: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS

Input:
(with-shadowed-custom-vars
  nil)

Output:
(defmacro with-shadowed-custom-vars (&body body)
  `(let ,(loop for (var) in *custom-vars*
            collect `(,var (if (boundp ',var) ,var)))
     ,@body))


Instruction:
Define a macro that eliminates this repetitive pattern:
(cmatch nil
  nil)

Issue: Macro call that should be transformed by CMATCH

Input:
(cmatch nil
  nil)

Output:
(defmacro cmatch (arg &body clauses)
  "Same as MATCH, except a continuable MATCH-ERROR will be raised if none of the
clauses match."
  (once-only (arg)
    (let ((else `(cerror "Continue."
                         'match-error
                         :values (list ,arg)
                         :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))
      (compile-match-1 arg clauses else))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(is nil :key nil)

Write a macro that addresses: Macro call that should be transformed by IS

Input: (is nil :key nil)

Output:
(defmacro is (got expected &rest args)
  (with-gensyms (duration result new-args desc)
    (once-only (expected)
      `(let* ((,new-args (list ,@args))
              (,desc (parse-description-and-test ,new-args)))
         (with-catching-errors (:description ,desc :expected ,expected)
           (with-duration ((,duration ,result) ,got)
             (test ,result ,expected ,new-args
                   :duration ,duration)))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(rotatef)

Write a macro that addresses: Macro call that should be transformed by ROTATEF

Input: (rotatef)

Output: (defmacro ROTATEF ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(f_%
  nil
  :key
  nil)

What needs to change: Macro call that should be transformed by F_%

Input:
(f_%
  nil
  :key
  nil)

Output: (defmacro F_% ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(in-compile-time nil
  (progn))

What needs to change: Macro call that should be transformed by IN-COMPILE-TIME

Input:
(in-compile-time nil
  (progn))

Output: (defmacro IN-COMPILE-TIME ...)


Instruction:
Generate a defmacro form that transforms code like this:
(call-method nil)

Pattern to recognize: Macro call that should be transformed by CALL-METHOD

Input: (call-method nil)

Output:
(defmacro call-method (method &optional methods)
  `(cl:call-method ,method ,methods))


Instruction:
Generate a defmacro form that transforms code like this:
(with-collectors nil
  :key
  nil)

Pattern to recognize: Macro call that should be transformed by WITH-COLLECTORS

Input:
(with-collectors nil
  :key
  nil)

Output:
(defmacro with-collectors ((&rest collectors) &body body)
  "Like `with-collector', with multiple collectors.
Returns the final value of each collector as multiple values.

     (with-collectors (x y z)
       (x 1)
       (y 2)
       (z 3))
     => '(1) '(2) '(3)"
  ;; Warn if there are duplications in COLLECTORS.
  (when (> (length collectors)
           (length (remove-duplicates collectors)))
    (warn "Duplicated collectors in with-collectors form: ~s" collectors))
  (with-gensyms (outer)
    `(block ,outer
       ,(reduce (lambda (form collector)
                  `(with-collector (,collector)
                     ,form))
                collectors
                :initial-value
                `(progn
                   ,@body
                   (return-from ,outer
                     (values ,@(mapcar #'list collectors))))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(=> nil (progn))

Problem: Macro call that should be transformed by =>

Input: (=> nil (progn))

Output:
(defmacro => (fn1 fn2 &rest fns)
  "Function composition of FN1, FN2 and all the other FNS."
  (let ((arg (gensym "ARG")))
    `(lambda (,arg)
       ,(if fns
            `(,fn1 (call (=> ,fn2 ,@fns) ,arg))
            `(,fn1 (,fn2 ,arg))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(tree-ecase 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by TREE-ECASE

Input: (tree-ecase 'lol-gen::some-name)

Output: (defmacro TREE-ECASE ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(example
  nil
  nil)

Write a macro that addresses: Macro call that should be transformed by EXAMPLE

Input:
(example
  nil
  nil)

Output:
(defmacro example (&body body)
  "Like `comment'."
  `(comment ,@body))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(is-true nil :key nil)

Problem: Macro call that should be transformed by IS-TRUE

Input: (is-true nil :key nil)

Output:
(defmacro is-true (condition &rest reason-args)
  "Like IS this check generates a pass if CONDITION returns true
  and a failure if CONDITION returns false. Unlike IS this check
  does not inspect CONDITION to determine how to report the
  failure."
  `(if ,condition
       (add-result 'test-passed :test-expr ',condition)
       (process-failure ',condition
                        ,@(or reason-args
                              `("~S did not return a true value" ',condition)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(for-all nil)

What needs to change: Macro call that should be transformed by FOR-ALL

Input: (for-all nil)

Output:
(defmacro for-all (bindings &body body)
  "Bind BINDINGS to random variables and test BODY *num-trials* times.

BINDINGS is a list of binding forms, each element is a list
of (BINDING VALUE &optional GUARD). Value, which is evaluated
once when the for-all is evaluated, must return a generator which
be called each time BODY is evaluated. BINDING is either a symbol
or a list which will be passed to destructuring-bind. GUARD is a
form which, if present, stops BODY from executing when IT returns
NIL. The GUARDS are evaluated after all the random data has been
generated and they can refer to the current value of any
binding. NB: Generator forms, unlike guard forms, can not contain
references to the bound variables.

Examples:

  (for-all ((a (gen-integer)))
    (is (integerp a)))

  (for-all ((a (gen-integer) (plusp a)))
    (is (integerp a))
    (is (plusp a)))

  (for-all ((less (gen-integer))
            (more (gen-integer) (< less more)))
    (is (<= less more)))

  (for-all (((a b) (gen-two-integers)))
    (is (integerp a))
    (is (integerp b)))"
  (with-gensyms (test-lambda-args)
    `(perform-random-testing
      (list ,@(mapcar #'second bindings))
      (lambda (,test-lambda-args)
        (destructuring-bind ,(mapcar #'first bindings)
            ,test-lambda-args
          (if (and ,@(delete-if #'null (mapcar #'third bindings)))
              (progn ,@body)
              (throw 'run-once
                (list :guard-conditions-failed))))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(multiple-value-bind nil (progn))

Write a macro that addresses: Macro call that should be transformed by MULTIPLE-VALUE-BIND

Input: (multiple-value-bind nil (progn))

Output: (defmacro MULTIPLE-VALUE-BIND ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(test 'lol-gen::some-name)

Problem: Macro call that should be transformed by TEST

Input: (test 'lol-gen::some-name)

Output:
(defmacro test (name &body body)
  "Create a test named NAME. If NAME is a list it must be of the
form:

  (name &key depends-on suite fixture compile-at profile)

NAME is the symbol which names the test.

DEPENDS-ON is a list of the form:

 (AND . test-names) - This test is run only if all of the tests
 in TEST-NAMES have passed, otherwise a single test-skipped
 result is generated.

 (OR . test-names) - If any of TEST-NAMES has passed this test is
 run, otherwise a test-skipped result is generated.

 (NOT test-name) - This is test is run only if TEST-NAME failed.

AND, OR and NOT can be combined to produce complex dependencies.

If DEPENDS-ON is a symbol it is interpreted as `(AND
,depends-on), this is accomadate the common case of one test
depending on another.

FIXTURE specifies a fixture to wrap the body in.

If PROFILE is T profiling information will be collected as well."
  (destructuring-bind (name &rest args)
      (ensure-list name)
    `(def-test ,name (,@args) ,@body)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(callf nil :key nil)

Problem: Macro call that should be transformed by CALLF

Input: (callf nil :key nil)

Output:
(defmacro callf (function place &rest args &environment env)
  "Set PLACE to the value of calling FUNCTION on PLACE, with ARGS."
  (multiple-value-bind (vars vals stores setter getter)
      (get-setf-expansion place env)
    `(let* ,(mapcar #'list vars vals)
       (multiple-value-bind ,stores
           (funcall ,function ,getter ,@args)
         ,setter))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(save-generator)

Write a macro that addresses: Macro call that should be transformed by SAVE-GENERATOR

Input: (save-generator)

Output:
(defmacro save-generator (&key name start-function in-package)
  `(defun ,name (name)
     (labels ((dump-start ()
		(in-package ,in-package)
		(setf (readtable-case *readtable*) :invert)
		#+sbcl (,start-function sb-ext:*posix-argv*)
		#+clozure (handler-case
			      (,start-function ccl::*command-line-argument-list*)
			    (error (err) (let ((*print-pretty* t))
					   (format *error-output* "~a" err)
					   (ccl::quit 1))))
		#+ecl (,start-function (loop for i from 0 below (si:argc) collect (si:argv i)))
		#-(or sbcl clozure ecl)
		(error "Missing implementation of 'save-generator' for your lisp implementation")
		))
       (net.didierverna.clon:dump name dump-start))))


Instruction:
Generate a defmacro form that transforms code like this:
(with-c-syntax common-lisp:nil
  :key
  common-lisp:nil)

Pattern to recognize: Macro call that should be transformed by WITH-C-SYNTAX

Input:
(with-c-syntax common-lisp:nil
  :key
  common-lisp:nil)

Output:
(defmacro with-c-syntax ((&rest options
			  &key (preprocess t)
                            (reader-level *with-c-syntax-reader-level*)
                            (readtable-case (or *with-c-syntax-reader-case*
                                                (readtable-case *readtable*)))
                            (input-file-pathname nil)
			    (try-add-{} t))
			 &environment *wcs-expanding-environment*
			 &body body)
  "This macro is a entry point of the with-c-syntax system. BODY will be
interpreted as C syntax, executed, and return values.

This macro returns the last form's value if BODY is a compound
statement, or returns NIL if BODY is a compilation unit.

PREPROCESS specifies how to do preprocess. If nil, this macro compiles
BODY without preprocessing. If t, preprocesses and compiles BODY. If
`:preprocess-only', this macro preprocesses BODY and returns the
result as-is.

READER-LEVEL specifies the reader level (see `*with-c-syntax-reader-level*').
This is used when '#include' or '_Pragma()' was used.

READTABLE-CASE specifies the readtable case of symbols in BODY when it
was read.  This affects how to intern C keywords by the preprocessor.

INPUT-FILE-PATHNAME is passed to the preprocessor and used when
'__FILE__' macro was used.

If TRY-ADD-{} is t and an error occurred at parsing, `with-c-syntax'
adds '{' and '}' into the head and tail of FORM respectively, and
tries to parse again."
  (cond
    ((null body)
     nil)
    ((and (length= 1 (the list body))	; with-c-syntax is nested.
	  (starts-with 'with-c-syntax (first body)))
     (destructuring-bind (op_ options2 &body body2)
	 (first body)
       (declare (ignore op_))
       `(with-c-syntax (,@options ,@options2) ,@body2)))
    (t
     (ecase preprocess
       (:preprocess-only
        (preprocessor body reader-level readtable-case input-file-pathname))
       (t
        `(with-c-syntax (:preprocess nil :try-add-{} ,try-add-{})
           ,@(preprocessor body reader-level readtable-case input-file-pathname)))
       ((nil)
        (expand-c-syntax body
		         try-add-{}))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(case 'lol-gen::some-name)

Issue: Macro call that should be transformed by CASE

Input: (case 'lol-gen::some-name)

Output: (defmacro CASE ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(summing-to nil)

What needs to change: Macro call that should be transformed by SUMMING-TO

Input: (summing-to nil)

Output: (defmacro SUMMING-TO ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(and-let* 'lol-gen::some-name)

Issue: Macro call that should be transformed by AND-LET*

Input: (and-let* 'lol-gen::some-name)

Output:
(defmacro and-let* ((&rest clauses) &body body &environment env)
  "Scheme's guarded LET* (SRFI-2).

Each clause should have one of the following forms:

- `identifier', in which case IDENTIFIER's value is tested.

- `(expression)', in which case the value of EXPRESSION is tested.

- `(identifier expression)' in which case EXPRESSION is evaluated,
    and, if its value is not false, IDENTIFIER is bound to that value
    for the remainder of the clauses and the optional body.

Note that, of course, the semantics are slightly different in Common
Lisp than in Scheme, because our AND short-circuits on null, not
false.

Also, this version makes the bindings immutable."
  (multiple-value-bind (body decls)
      (parse-body body)
    (labels ((expand (clauses body)
               (unsplice
                (ematch clauses
                  (() (if body `(progn ,@body) nil))
                  ((list* (and var (type symbol)) clauses)
                   `(and ,var ,@(expand clauses body)))
                  ((list* (list var expr) clauses)
                   (let ((temp (gensym (string var))))
                     (multiple-value-bind (local-decls other-decls)
                         (partition-declarations (list var) decls env)
                       ;; The use of the temporary here is so we still
                       ;; get style warnings if the variable is
                       ;; unused.
                       `(let* ((,temp ,expr)
                               (,var ,temp))
                          ,@local-decls
                          (and ,temp
                               ,@(expand clauses
                                         (append other-decls body)))))))
                  ((list* (list expr) clauses)
                   `(and ,expr ,@(expand clauses body)))))))
      (car (expand clauses body)))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(nix 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by NIX

Input: (nix 'lol-gen::some-name)

Output:
(defmacro nix (&rest places)
  "Set PLACES to nil and return the old value(s) of PLACES.

If there is more than one PLACE, return their old values as multiple values.

This may be more efficient than (shiftf place nil), because it only
sets PLACE when it is not already null."
  `(values
    ,@(loop for place in places
            collect `(nix-1 ,place))))


Instruction:
Generate a defmacro form that transforms code like this:
(cond-it)

Pattern to recognize: Macro call that should be transformed by COND-IT

Input: (cond-it)

Output:
(defmacro cond-it (&body body)
  "Like COND. IT is bound to the passed COND test."
  `(let (it)
     (cond
       ,@(mapcar (lambda (clause)
                   `((setf it ,(car clause)) ,@(cdr clause)))
                 ;; uses the fact, that SETF returns the value set
                 body))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(gatherlet nil
  nil)

Issue: Macro call that should be transformed by GATHERLET

Input:
(gatherlet nil
  nil)

Output: (defmacro GATHERLET ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(cond->)

Problem: Macro call that should be transformed by COND->

Input: (cond->)

Output: (defmacro COND-> ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-special-initargs* nil
  nil)

What needs to change: Macro call that should be transformed by WITH-SPECIAL-INITARGS*

Input:
(with-special-initargs* nil
  nil)

Output: (defmacro WITH-SPECIAL-INITARGS* ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(pushnew nil nil)

Problem: Macro call that should be transformed by PUSHNEW

Input: (pushnew nil nil)

Output: (defmacro PUSHNEW ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-test+run nil
  :key
  nil)

Issue: Macro call that should be transformed by DEFINE-TEST+RUN

Input:
(define-test+run nil
  :key
  nil)

Output:
(defmacro define-test+run (name &body args-and-body)
  `(progn
     (define-test ,name ,@args-and-body)
     (eval-when (:execute)
       (let* ((*silence-plain-compilation-errors-p* nil) ; must be let*! the order matters!
              (report (test ',name :report 'plain)))
         (if (member (status report) '(:passed :skipped))
             report
             (values report
                     (loop for result across (results report)
                           when (and (not (typep result 'test-result))
                                     (eql :failed (status result)))
                           collect (expression result))))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(ignorable 'lol-gen::some-name)

Problem: Macro call that should be transformed by IGNORABLE

Input: (ignorable 'lol-gen::some-name)

Output: (defmacro IGNORABLE ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(some-<>> nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by SOME-<>>

Input:
(some-<>> nil
  (progn))

Output: (defmacro some-<>> (init &body exps) (diamond-wand init exps t t))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(empty)

What needs to change: Macro call that should be transformed by EMPTY

Input: (empty)

Output: (defmacro EMPTY ...)


Instruction:
Generate a defmacro form that transforms code like this:
(as common-lisp:nil (common-lisp:progn))

Pattern to recognize: Macro call that should be transformed by AS

Input: (as common-lisp:nil (common-lisp:progn))

Output:
(defmacro as (type cl:&optional (expr cl:nil expr-supplied-p))
  "A syntactic convenience for type casting.

    (as <type> <expr>)

is equivalent to

    (the <type> (into <expr>))

and

    (as <type>)

is equivalent to

    (fn (expr) (the <type> (into expr))).

Note that this may copy the object or allocate memory."

  (cl:let ((into (cl:ignore-errors (cl:find-symbol "INTO" "COALTON/CLASSES"))))
    (cl:assert into () "`as` macro does not have access to `into` yet.")
    (cl:if expr-supplied-p
           `(the ,type (,into ,expr))
           (alexandria:with-gensyms (lexpr)
             `(fn (,lexpr)
                (the ,type (,into ,lexpr)))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(ensure-functionf)

Write a macro that addresses: Macro call that should be transformed by ENSURE-FUNCTIONF

Input: (ensure-functionf)

Output:
(defmacro ensure-functionf (&rest places)
  "Multiple-place modify macro for ENSURE-FUNCTION: ensures that each of
PLACES contains a function."
  `(progn ,@(mapcar (lambda (x) `(ensure-functionf/1 ,x)) places)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(c-formula 'lol-gen::some-name)

Problem: Macro call that should be transformed by C-FORMULA

Input: (c-formula 'lol-gen::some-name)

Output:
(defmacro c-formula ((&rest keys &key lazy &allow-other-keys) &body forms)
  (assert (member lazy '(nil t :once-asked :until-asked :always)))
  `(make-c-dependent
    :code ',forms
    :value-state :unevaluated
    :rule (c-lambda ,@forms)
    ,@keys))


Instruction:
Define a macro that eliminates this repetitive pattern:
(make-dispatcher nil)

Issue: Macro call that should be transformed by MAKE-DISPATCHER

Input: (make-dispatcher nil)

Output:
(defmacro make-dispatcher (function-constructor)
  `(make-instance 'dispatcher :dispatch-function-constructor ',function-constructor
                  :dispatch-function ,function-constructor))


Instruction:
Define a macro that eliminates this repetitive pattern:
(psetf nil (progn))

Issue: Macro call that should be transformed by PSETF

Input: (psetf nil (progn))

Output: (defmacro PSETF ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(producing nil nil)

Problem: Macro call that should be transformed by PRODUCING

Input: (producing nil nil)

Output: (defmacro PRODUCING ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(nest nil)

What needs to change: Macro call that should be transformed by NEST

Input: (nest nil)

Output:
(defmacro nest (&rest things)
  "Like ~>>, but backward.

This is useful when layering `with-x' macros where the order is not
important, and extra indentation would be misleading.

For example:

    (nest
     (with-open-file (in file1 :direction input))
     (with-open-file (in file2 :direction output))
     ...)

Is equivalent to:

    (with-open-file (in file1 :direction input)
      (with-open-file (in file2 :direction output)
        ...))

\(But see `with-open-files').

If the outer macro has no arguments, you may omit the parentheses.

    (nest
      with-standard-io-syntax
      ...)
    ≡ (with-standard-io-syntax
        ...)

From UIOP, based on a suggestion by Marco Baringer."
  (expand-nest things))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(order-by nil (progn))

Problem: Macro call that should be transformed by ORDER-BY

Input: (order-by nil (progn))

Output:
(defmacro order-by (&rest expressions)
  `(make-clause :order-by ,@(expand-expression expressions)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(define-test+run nil)

Problem: Macro call that should be transformed by DEFINE-TEST+RUN

Input: (define-test+run nil)

Output:
(defmacro define-test+run (name &body args-and-body)
  `(progn
     (define-test ,name ,@args-and-body)
     (eval-when (:execute)
       (let* ((*silence-plain-compilation-errors-p* nil) ; must be let*! the order matters!
              (report (test ',name :report 'plain)))
         (if (member (status report) '(:passed :skipped))
             report
             (values report
                     (loop for result across (results report)
                           when (and (not (typep result 'test-result))
                                     (eql :failed (status result)))
                           collect (expression result))))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(define-vari-macro nil
    (progn))

Write a macro that addresses: Macro call that should be transformed by DEFINE-VARI-MACRO

Input:
(define-vari-macro nil
    (progn))

Output:
(defmacro define-vari-macro (name lambda-list &body body)
  (check-args-for-constant-names :macro name lambda-list)
  (vbind (func-code context) (gen-macro-function-code name lambda-list body)
    `(progn
       (add-global-form-binding
        (make-regular-macro ',name ,func-code ',context nil))
       ',name)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(esc nil :key nil)

Problem: Macro call that should be transformed by ESC

Input: (esc nil :key nil)

Output:
(defmacro esc (&rest forms)
  `(list
    ,@(loop for form in forms
            collect (%escape-string-form form))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(ekx nil (progn))

Write a macro that addresses: Macro call that should be transformed by EKX

Input: (ekx nil (progn))

Output:
(defmacro ekx (ekx-id &rest body)
  (let ((result (gensym)))
     `(let ((,result (,@body)))
         (trc ,(string-downcase (symbol-name ekx-id)) :=> ,result)
         ,result)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(fdec nil nil)

What needs to change: Macro call that should be transformed by FDEC

Input: (fdec nil nil)

Output:
(defmacro fdec (place &optional (delta 1))
  "DEPRECATED: use `shift-decf' instead."
  (simple-style-warning "~s is deprecated, use ~s instead"
                        'finc 'shift-incf)
  `(shift-decf ,place ,delta))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(secase nil
  nil)

What needs to change: Macro call that should be transformed by SECASE

Input:
(secase nil
  nil)

Output:
(defmacro secase (keyform &body cases)
  "Like ECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the
scope of the cases. IT can be set with SETF."
  `(symbolic ecase ,keyform ,@cases))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(jwhen nil)

What needs to change: Macro call that should be transformed by JWHEN

Input: (jwhen nil)

Output:
(defmacro jwhen (test &body body)
  "JSON-aware version of `cl:when'.
If TEST is `jtruep' evaluate BODY."
  `(jif ,test
       (progn ,@body)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(collect-hash nil nil)

What needs to change: Macro call that should be transformed by COLLECT-HASH

Input: (collect-hash nil nil)

Output: (defmacro COLLECT-HASH ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(dolist (quote lol-gen::some-name))

Write a macro that addresses: Macro call that should be transformed by DOLIST

Input: (dolist (quote lol-gen::some-name))

Output: (defmacro DOLIST ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(define-language-macro 'lol-gen::some-name)

Problem: Macro call that should be transformed by DEFINE-LANGUAGE-MACRO

Input: (define-language-macro 'lol-gen::some-name)

Output: (defmacro DEFINE-LANGUAGE-MACRO ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(wnotrc nil
  :key
  nil)

Issue: Macro call that should be transformed by WNOTRC

Input:
(wnotrc nil
  :key
  nil)

Output:
(defmacro wnotrc ((&optional (min 1) (max 50) &rest banner) &body body )
  (declare (ignore min max banner))
  `(progn ,@body))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(group-by nil nil)

What needs to change: Macro call that should be transformed by GROUP-BY

Input: (group-by nil nil)

Output:
(defmacro group-by (&rest expressions)
  `(apply #'make-clause :group-by ',expressions))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(~> nil :key nil)

Write a macro that addresses: Macro call that should be transformed by ~>

Input: (~> nil :key nil)

Output:
(defmacro ~> (needle &rest holes)
  "Threading macro from Clojure (by way of Racket).

Thread NEEDLE through HOLES, where each hole is either a
symbol (equivalent to `(hole needle)`) or a list (equivalent to `(hole
needle args...)`).

As an extension, an underscore in the argument list is replaced with
the needle, so you can pass the needle as an argument other than the
first."
  (thread-aux '~> needle holes
              (lambda (needle hole)
                (list* (car hole) needle (cdr hole)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(opf nil (progn))

Issue: Macro call that should be transformed by OPF

Input: (opf nil (progn))

Output:
(defmacro opf (place expr)
  "Like `(callf PLACE (op EXPR))'.
From GOO."
  `(callf (op ,expr) ,place))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(reversef 'lol-gen::some-name)

Problem: Macro call that should be transformed by REVERSEF

Input: (reversef 'lol-gen::some-name)

Output: (defmacro REVERSEF ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
;; Manual gensym creation is boilerplate-heavy
(defmacro with-temp (var &body body)
  (let ((g (gensym)))
    `(let ((,g ,var))
       ,@body)))
;; Every macro needs this pattern - repetitive and error-prone

Write a macro that addresses: Repeated gensym boilerplate in macro definitions — want automatic gensym creation from naming convention

Input:
;; Manual gensym creation is boilerplate-heavy
(defmacro with-temp (var &body body)
  (let ((g (gensym)))
    `(let ((,g ,var))
       ,@body)))
;; Every macro needs this pattern - repetitive and error-prone

Output:
(defun g!-symbol-p (s)
  (and (symbolp s)
       (> (length (symbol-name s)) 2)
       (string= (symbol-name s)
                "G!"
                :start1 0
                :end1 2)))

(defmacro defmacro/g! (name args &rest body)
  (let ((syms (remove-duplicates
               (remove-if-not #'g!-symbol-p
                              (flatten body)))))
    (multiple-value-bind (body declarations docstring)
        (parse-body body :documentation t)
      `(defmacro ,name ,args
         ,@(when docstring
             (list docstring))
         ,@declarations
         (let ,(mapcar
                (lambda (s)
                  `(,s (gensym ,(subseq
                                 (symbol-name s)
                                 2))))
                syms)
           ,@body)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(jmatch nil)

What needs to change: Macro call that should be transformed by JMATCH

Input: (jmatch nil)

Output:
(defmacro jmatch (form &body clauses)
  "Similar to Trivia match macro, match the FORM (JSON value) against CLAUSES.
CLAUSES are (PATTERN . BODY) forms, where
- PATTERN is a `jbind' destructuring pattern.
- And BODY is an implicit progn.

If PATTERN matches successfully in `jbind', then BODY is executed with
the variables from the PATTERN bound to the respective values, as per
`jbind'.

The last clause could start with T, OTHERWISE, ELSE, or _, and it will
be invoked if other patterns don't match. If there's no such clause,
`jmatch' will simply return NIL on no matching patterns."
  (let ((form-sym (gensym "MATCH-FORM")))
    `(let ((,form-sym ,form))
       (cond
         ,@(loop for (pattern . body) in clauses
                 when (and (symbolp pattern)
                           (member (symbol-name pattern) '("T" "_" "OTHERWISE" "ELSE")
                                   :test #'string=))
                   collect `(t ,@body)
                 else
                   collect `((ignore-errors (jbind ,pattern ,form-sym t))
                             (jbind ,pattern ,form-sym ,@body)))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(compile-$flavor-$methods)

Write a macro that addresses: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS

Input: (compile-$flavor-$methods)

Output: (defmacro COMPILE-$FLAVOR-$METHODS ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(when-failing nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by WHEN-FAILING

Input:
(when-failing nil
  (progn))

Output: (defmacro WHEN-FAILING ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(drelet* nil
  :key
  nil)

Problem: Macro call that should be transformed by DRELET*

Input:
(drelet* nil
  :key
  nil)

Output: (defmacro DRELET* ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(some-<>> nil
  :key
  nil)

What needs to change: Macro call that should be transformed by SOME-<>>

Input:
(some-<>> nil
  :key
  nil)

Output: (defmacro some-<>> (init &body exps) (diamond-wand init exps t t))


Instruction:
Define a macro that eliminates this repetitive pattern:
(group 'lol-gen::some-name)

Issue: Macro call that should be transformed by GROUP

Input: (group 'lol-gen::some-name)

Output:
(defmacro group ((name &optional description &rest format-args) &body tests)
  `(eval-in-context
    *context*
    (make-instance 'group-result
                   :expression ',name
                   :body (lambda () ,@tests)
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(ematch common-lisp:nil)

Problem: Macro call that should be transformed by EMATCH

Input: (ematch common-lisp:nil)

Output:
(defmacro ematch (what &body clauses)
  #.+match-doc+
  (with-gensyms (otherwise)
    `(match2 ,what
       ,@clauses
       (,otherwise (error 'match-error :pattern ',clauses :values (list ,otherwise))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(defmethod* nil
    (progn))

Problem: Macro call that should be transformed by DEFMETHOD*

Input:
(defmethod* nil
    (progn))

Output: (defmacro DEFMETHOD* ...)


Instruction:
Generate a defmacro form that transforms code like this:
(with-thunk 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by WITH-THUNK

Input: (with-thunk 'lol-gen::some-name)

Output:
(defmacro with-thunk ((spec &rest args) &body body)
  "A macro-writing macro for the `call-with-' style.

In the `call-with-' style of writing macros, the macro is simply a
syntactic convenience that wraps its body in a thunk and a call to the
function that does the actual work.

    (defmacro with-foo (&body body)
      `(call-with-foo (lambda () ,@body)))

The `call-with-' style has many advantages. Functions are easier to
write than macros; you can change the behavior of a function without
having to recompile all its callers; functions can be traced, appear
in backtraces, etc.

But meanwhile, all those thunks are being allocated on the heap. Can
we avoid this? Yes, but at a high cost in boilerplate: the closure has
to be given a name (using `flet') so it can be declared
`dynamic-extent'.

    (defmacro with-foo (&body body)
      (with-gensyms (thunk)
        `(flet ((,thunk () ,@body))
           (declare (dynamic-extent #',thunk))
           (call-with-foo #',thunk))))

`with-thunk' avoids the boilerplate:

    (defmacro with-foo (&body body)
      (with-thunk (body)
        `(call-with-foo ,body)))

You can give the thunk a name for easier debugging.

    (with-thunk ((body :name foo)) ...)

It is also possible to construct a \"thunk\" with arguments.

    (with-thunk (body foo)
      `(call-with-foo ,body))
    ≡ `(flet ((,thunk (,foo)
          ,@body))
        (declare (dynamic-extent #',thunk))
        (call-with-foo #',thunk))

Someday this may have a better name."
  ;; TODO Derive default name from &environment. Cf. log4cl.
  (destructuring-bind (var &key name) (ensure-list spec)
    (declare (type (and symbol (not null)) var)
             (type symbol name))
    (let* ((stack-fn-prefix (string 'stack-fn-))
           (stack-fn-name
             (or (concatenate 'string
                              stack-fn-prefix
                              (string (or name var)))))
           (stack-fn
             (gensym stack-fn-name)))
      (with-gensyms (b gargs)
        `(let ((,b ,var)
               (,var ',stack-fn)
               (,gargs (list ,@args)))
           `(flet ((,',stack-fn ,,gargs
                     ,@,b))
              (declare (dynamic-extent (function ,',stack-fn)))
              (symbol-macrolet ((,',stack-fn (function ,',stack-fn)))
                ,,@body)))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(delete-from-plistf nil)

Problem: Macro call that should be transformed by DELETE-FROM-PLISTF

Input: (delete-from-plistf nil)

Output: (defmacro DELETE-FROM-PLISTF ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(defmacro+ps nil
    nil)

Problem: Macro call that should be transformed by DEFMACRO+PS

Input:
(defmacro+ps nil
    nil)

Output: (defmacro DEFMACRO+PS ...)


Instruction:
Generate a defmacro form that transforms code like this:
(sor nil)

Pattern to recognize: Macro call that should be transformed by SOR

Input: (sor nil)

Output:
(defmacro sor (first &rest rest)
  "Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for
the scope of the rest of the arguments. IT can be set with SETF."
  `(symbolic or ,first ,@rest))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(skip)

Problem: Macro call that should be transformed by SKIP

Input: (skip)

Output:
(defmacro skip (&rest reason)
  "Generates a TEST-SKIPPED result."
  `(add-result 'test-skipped :reason (format nil ,@reason)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(fbindrec nil
  (progn))

What needs to change: Macro call that should be transformed by FBINDREC

Input:
(fbindrec nil
  (progn))

Output:
(defmacro fbindrec (bindings &body body &environment *lexenv*)
  "Like `fbind', but creates recursive bindings.

The consequences of referring to one binding in the expression that
generates another are undefined."
  (setf bindings (expand-fbindings bindings))
  (unless bindings
    (return-from fbindrec `(locally ,@body)))
  (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))
           (body decls (parse-body body))
           (simple complex lambda unref
            (partition-fbinds (append bindings lambdas)
                              body))
           (temps (mapcar (op (gensym (string (first _)))) complex))
           (simple-decls complex-decls lambda-decls others
            (partition-declarations-by-kind simple complex lambda decls)))
    `(let ,env
       ,@(unsplice (and env-decls `(declare ,@env-decls)))
       ;; Simple expressions reference functions already defined
       ;; outside of the letrec, so we can handle them with fbind.
       (comment "fbind: Simple")
       (fbind ,simple
         ,@simple-decls
         (comment "fbind: Temps for complex bindings")
         (let ,(loop for temp in temps collect `(,temp #'invalid))
           (declare ,@(loop for temp in temps collect `(function ,temp)))
           (flet ,(loop for (name nil) in complex
                        for temp in temps
                        collect (build-bind/ftype name temp complex-decls env))
             ,@complex-decls
             (comment "fbind: Lambdas")
             (labels (,@(loop for (name lambda) in lambda
                              collect `(,name ,@(cdr lambda))))
               ,@lambda-decls
               (comment "fbind: Unreferenced")
               (progn ,@(mapcar #'second unref))
               (comment "fbind: Complex")
               (psetf ,@(loop for temp in temps
                              for (nil expr) in complex
                              append `(,temp (ensure-function ,expr))))
               (locally ,@others
                 ,@body))))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(f_n
  nil
  nil)

Write a macro that addresses: Macro call that should be transformed by F_N

Input:
(f_n
  nil
  nil)

Output: (defmacro F_N ...)


Instruction:
Generate a defmacro form that transforms code like this:
(unwrap-as common-lisp:nil common-lisp:nil)

Pattern to recognize: Macro call that should be transformed by UNWRAP-AS

Input: (unwrap-as common-lisp:nil common-lisp:nil)

Output:
(defmacro unwrap-as (type cl:&optional (expr cl:nil expr-supplied-p))
  "A syntactic convenience for type casting.

    (unwrap-as <type> <expr>)

is equivalent to

    (the <type> (uwrap (tryInto <expr>)))

and

    (unwrap-as <type>)

is equivalent to

    (fn (expr) (the <type> (unwrap (tryInto expr)))).

Note that this may copy the object or allocate memory."

  (cl:let ((try-into (cl:ignore-errors (cl:find-symbol "TRYINTO" "COALTON/CLASSES")))
           (unwrap (cl:ignore-errors (cl:find-symbol "UNWRAP" "COALTON/CLASSES"))))
    (cl:assert try-into () "`try-as` macro does not have access to `try-into` yet.")
    (cl:assert unwrap () "`unwrap` macro does not have access to `unwrap` yet.")
    (cl:if expr-supplied-p
           `(the ,type (,unwrap (,try-into ,expr)))
           (alexandria:with-gensyms (lexpr)
             `(fn (,lexpr)
                (the ,type (,unwrap (,try-into ,lexpr))))))))


Instruction:
Generate a defmacro form that transforms code like this:
(the-part nil (progn))

Pattern to recognize: Macro call that should be transformed by THE-PART

Input: (the-part nil (progn))

Output: (defmacro THE-PART ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(optimize common-lisp:nil
  (common-lisp:progn))

Problem: Macro call that should be transformed by OPTIMIZE

Input:
(optimize common-lisp:nil
  (common-lisp:progn))

Output: (defmacro OPTIMIZE ...)


Instruction:
Generate a defmacro form that transforms code like this:
(compile-$flavor-$methods nil nil)

Pattern to recognize: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS

Input: (compile-$flavor-$methods nil nil)

Output: (defmacro COMPILE-$FLAVOR-$METHODS ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(use-foreign-library 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by USE-FOREIGN-LIBRARY

Input: (use-foreign-library 'lol-gen::some-name)

Output:
(defmacro use-foreign-library (name)
  `(load-foreign-library ',name))


Instruction:
Define a macro that eliminates this repetitive pattern:
(counting 'lol-gen::some-name)

Issue: Macro call that should be transformed by COUNTING

Input: (counting 'lol-gen::some-name)

Output: (defmacro COUNTING ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(unless-match common-lisp:nil
    :key
  common-lisp:nil)

Problem: Macro call that should be transformed by UNLESS-MATCH

Input:
(unless-match common-lisp:nil
    :key
  common-lisp:nil)

Output:
(defmacro unless-match (pattern arg &body body)
  "Equivalent to (match ARG (PATTERN) (_ BODY...))."
  `(match ,arg
     (,pattern)
     (_ ,.body)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(order-by nil (progn))

Problem: Macro call that should be transformed by ORDER-BY

Input: (order-by nil (progn))

Output: (defmacro ORDER-BY ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(lambda () (progn))

What needs to change: Macro call that should be transformed by LAMBDA

Input: (lambda () (progn))

Output: (defmacro LAMBDA ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(is nil nil)

Problem: Macro call that should be transformed by IS

Input: (is nil nil)

Output:
(defmacro is (test &rest reason-args)
  "The DWIM checking operator.

If TEST returns a true value a test-passed result is generated,
otherwise a test-failure result is generated. The reason, unless
REASON-ARGS is provided, is generated based on the form of TEST:

 (predicate expected actual) - Means that we want to check
 whether, according to PREDICATE, the ACTUAL value is
 in fact what we EXPECTED.

 (predicate value) - Means that we want to ensure that VALUE
 satisfies PREDICATE.

 Wrapping the TEST form in a NOT simply produces a negated reason
 string."
  (assert (listp test)
          (test)
          "Argument to IS must be a list, not ~S" test)
  (let (bindings effective-test default-reason-args)
    (with-gensyms (e a v)
      (flet ((process-entry (predicate expected actual &optional negatedp)
               ;; make sure EXPECTED is holding the entry that starts with 'values
               (when (and (consp actual)
                          (eq (car actual) 'values))
                 (assert (not (and (consp expected)
                                   (eq (car expected) 'values))) ()
                                   "Both the expected and actual part is a values expression.")
                 (rotatef expected actual))
               (let ((setf-forms))
                 (if (and (consp expected)
                          (eq (car expected) 'values))
                     (progn
                       (setf expected (copy-list expected))
                       (setf setf-forms (loop for cell = (rest expected) then (cdr cell)
                                              for i from 0
                                              while cell
                                              when (eq (car cell) '*)
                                              collect `(setf (elt ,a ,i) nil)
                                              and do (setf (car cell) nil)))
                       (setf bindings (list (list e `(list ,@(rest expected)))
                                            (list a `(multiple-value-list ,actual)))))
                     (setf bindings (list (list e expected)
                                          (list a actual))))
                 (setf effective-test `(progn
                                         ,@setf-forms
                                         ,(if negatedp
                                              `(not (,predicate ,e ,a))
                                              `(,predicate ,e ,a)))))))
        (list-match-case test
          ((not (?predicate ?expected ?actual))
           (process-entry ?predicate ?expected ?actual t)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)"
                       `',?actual a `',?predicate e)))
          ((not (?satisfies ?value))
           (setf bindings (list (list v ?value))
                 effective-test `(not (,?satisfies ,v))
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)"
                       `',?value v `',?satisfies)))
          ((?predicate ?expected ?actual)
           (process-entry ?predicate ?expected ?actual)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%"
                       `',?actual a `',?predicate e)))
          ((?satisfies ?value)
           (setf bindings (list (list v ?value))
                 effective-test `(,?satisfies ,v)
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%"
                       `',?value v `',?satisfies)))
          (?_
           (setf bindings '()
                 effective-test test
                 default-reason-args (list "~2&~S~2% was NIL." `',test)))))
      `(let ,bindings
         (if ,effective-test
             (add-result 'test-passed :test-expr ',test)
             (process-failure ',test
                              ,@(or reason-args default-reason-args)))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(dynamic-reprogv nil
    (progn))

Problem: Macro call that should be transformed by DYNAMIC-REPROGV

Input:
(dynamic-reprogv nil
    (progn))

Output: (defmacro DYNAMIC-REPROGV ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(cond-> 'lol-gen::some-name)

Problem: Macro call that should be transformed by COND->

Input: (cond-> 'lol-gen::some-name)

Output: (defmacro cond-> (init &body exps) (cond-arrow-macro init exps))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(defun nil ())

What needs to change: Macro call that should be transformed by DEFUN

Input: (defun nil ())

Output: (defmacro DEFUN ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(ensure-transaction
  nil
  nil)

Problem: Macro call that should be transformed by ENSURE-TRANSACTION

Input:
(ensure-transaction
  nil
  nil)

Output:
(defmacro ensure-transaction (&body body)
  "Ensures that body is executed within a transaction, but does not begin a new
transaction if one is already in progress."
  `(call-with-ensured-transaction (lambda () ,@body)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(finding nil nil)

What needs to change: Macro call that should be transformed by FINDING

Input: (finding nil nil)

Output: (defmacro FINDING ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-builder 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by WITH-BUILDER

Input: (with-builder 'lol-gen::some-name)

Output: (defmacro WITH-BUILDER ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-context-variables 'lol-gen::some-name)

Issue: Macro call that should be transformed by WITH-CONTEXT-VARIABLES

Input: (with-context-variables 'lol-gen::some-name)

Output:
(defmacro with-context-variables ((&rest vars) &body body)
  `(symbol-macrolet
       ,(loop for var in vars
              for form = `(context ,(intern (string var) :keyword))
              collect `(,var ,form))
     ,@body))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(rotatef 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by ROTATEF

Input: (rotatef 'lol-gen::some-name)

Output: (defmacro ROTATEF ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(lambda-ematch1 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by LAMBDA-EMATCH1

Input: (lambda-ematch1 'lol-gen::some-name)

Output:
(defmacro lambda-ematch1 (pattern &body body)
  "Equivalent to (lambda (arg) (ematch arg (PATTERN BODY...)))."
  `(lambda-ematch (,pattern ,@body)))


Instruction:
Generate a defmacro form that transforms code like this:
(defiter nil
    :key
  nil)

Pattern to recognize: Macro call that should be transformed by DEFITER

Input:
(defiter nil
    :key
  nil)

Output: (defmacro DEFITER ...)


Instruction:
Generate a defmacro form that transforms code like this:
(destructuring-case 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by DESTRUCTURING-CASE

Input: (destructuring-case 'lol-gen::some-name)

Output:
(defmacro destructuring-case (keyform &body clauses)
  "DESTRUCTURING-CASE, -CCASE, and -ECASE are a combination of CASE and DESTRUCTURING-BIND.
KEYFORM must evaluate to a CONS.

Clauses are of the form:

  ((CASE-KEYS . DESTRUCTURING-LAMBDA-LIST) FORM*)

The clause whose CASE-KEYS matches CAR of KEY, as if by CASE, CCASE, or ECASE,
is selected, and FORMs are then executed with CDR of KEY is destructured and
bound by the DESTRUCTURING-LAMBDA-LIST.

Example:

 (defun dcase (x)
   (destructuring-case x
     ((:foo a b)
      (format nil \"foo: ~S, ~S\" a b))
     ((:bar &key a b)
      (format nil \"bar: ~S, ~S\" a b))
     (((:alt1 :alt2) a)
      (format nil \"alt: ~S\" a))
     ((t &rest rest)
      (format nil \"unknown: ~S\" rest))))

  (dcase (list :foo 1 2))        ; => \"foo: 1, 2\"
  (dcase (list :bar :a 1 :b 2))  ; => \"bar: 1, 2\"
  (dcase (list :alt1 1))         ; => \"alt: 1\"
  (dcase (list :alt2 2))         ; => \"alt: 2\"
  (dcase (list :quux 1 2 3))     ; => \"unknown: 1, 2, 3\"

 (defun decase (x)
   (destructuring-case x
     ((:foo a b)
      (format nil \"foo: ~S, ~S\" a b))
     ((:bar &key a b)
      (format nil \"bar: ~S, ~S\" a b))
     (((:alt1 :alt2) a)
      (format nil \"alt: ~S\" a))))

  (decase (list :foo 1 2))        ; => \"foo: 1, 2\"
  (decase (list :bar :a 1 :b 2))  ; => \"bar: 1, 2\"
  (decase (list :alt1 1))         ; => \"alt: 1\"
  (decase (list :alt2 2))         ; => \"alt: 2\"
  (decase (list :quux 1 2 3))     ; =| error
"
  (expand-destructuring-case keyform clauses 'case))


Instruction:
Define a macro that eliminates this repetitive pattern:
(skip nil (progn))

Issue: Macro call that should be transformed by SKIP

Input: (skip nil (progn))

Output:
(defmacro skip (&rest reason)
  "Generates a TEST-SKIPPED result."
  `(add-result 'test-skipped :reason (format nil ,@reason)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(define-simple-documentation-lookup nil nil)

Write a macro that addresses: Macro call that should be transformed by DEFINE-SIMPLE-DOCUMENTATION-LOOKUP

Input: (define-simple-documentation-lookup nil nil)

Output:
(defmacro define-simple-documentation-lookup (class documentation-type)
  `(defmethod documentation ((,class ,class))
     ,(if (eql documentation-type T)
          `(cl:documentation (object ,class) 'T)
          `(cl:documentation (designator ,class) ',documentation-type))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(set= nil)

Problem: Macro call that should be transformed by SET=

Input: (set= nil)

Output:
(defmacro set= (&rest args)
  `(make-clause :set= ,@(mapcar #'expand-op args)))


Instruction:
Generate a defmacro form that transforms code like this:
(make-kid nil (progn))

Pattern to recognize: Macro call that should be transformed by MAKE-KID

Input: (make-kid nil (progn))

Output:
(defmacro make-kid (class &rest ia)
  (with-gensyms (c)
    `(let ((,c ,class))
       (make-instance ,c
         ,@ia
         :fm-parent (progn (assert self () "make-kid: self nil making ~a" ,c)
                      self)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(restart-bind nil
  nil)

What needs to change: Macro call that should be transformed by RESTART-BIND

Input:
(restart-bind nil
  nil)

Output: (defmacro RESTART-BIND ...)


Instruction:
Generate a defmacro form that transforms code like this:
(match2* common-lisp:nil)

Pattern to recognize: Macro call that should be transformed by MATCH2*

Input: (match2* common-lisp:nil)

Output:
(defmacro match2* (whats &body clauses)
  "In match2/match2*, the last clause is not enclosed in a block.
Therefore, using `next' in the last clause results in jumping to the next innermost matching construct,
or results in a compilation error when this is the outermost matching construct."
  `(match2*+ ,whats
       ,(make-list (length whats) :initial-element t)
     ;; ,(mapcar #'form-type whats)
     ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^ TODO: use Bike/compiler-macro
     ,@clauses))


Instruction:
Define a macro that eliminates this repetitive pattern:
(defclause nil
    (progn))

Issue: Macro call that should be transformed by DEFCLAUSE

Input:
(defclause nil
    (progn))

Output:
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(eko-if nil nil)

Write a macro that addresses: Macro call that should be transformed by EKO-IF

Input: (eko-if nil nil)

Output:
(defmacro eko-if ((&rest trcargs) &rest body)
  (let ((result (gensym)))
     `(let ((,result ,@body))
         (when ,result
           (trc ,(car trcargs) :res ,result ,@(cdr trcargs)))
         ,result)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(dreletf nil
  nil)

Write a macro that addresses: Macro call that should be transformed by DRELETF

Input:
(dreletf nil
  nil)

Output: (defmacro DRELETF ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-accessors nil
    (progn))

Problem: Macro call that should be transformed by WITH-ACCESSORS

Input:
(with-accessors nil
    (progn))

Output: (defmacro WITH-ACCESSORS ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(iterate
  nil
  (progn))

Issue: Macro call that should be transformed by ITERATE

Input:
(iterate
  nil
  (progn))

Output:
(defmacro iterate (&body body)
  "Jonathan Amsterdam's powerful iteration facility"
  `(iter .,body))


Instruction:
Define a macro that eliminates this repetitive pattern:
(disable-curly-syntax)

Issue: Macro call that should be transformed by DISABLE-CURLY-SYNTAX

Input: (disable-curly-syntax)

Output: (defmacro DISABLE-CURLY-SYNTAX ...)


Instruction:
Generate a defmacro form that transforms code like this:
(lambda (quote lol-gen::some-name))

Pattern to recognize: Macro call that should be transformed by LAMBDA

Input: (lambda (quote lol-gen::some-name))

Output: (defmacro LAMBDA ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(all nil :key nil)

Issue: Macro call that should be transformed by ALL

Input: (all nil :key nil)

Output:
(defmacro all (parser &rest parsers)
  "Combination of parsers yielding all results as a list."
  `(<*> ,parser ,@parsers))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(unless nil (progn))

Write a macro that addresses: Macro call that should be transformed by UNLESS

Input: (unless nil (progn))

Output: (defmacro UNLESS ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-fixtures nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by WITH-FIXTURES

Input:
(with-fixtures nil
  (progn))

Output:
(defmacro with-fixtures (fixtures &body body)
  `(call-with-fixtures (lambda () ,@body) ,fixtures))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(lambda-match
  nil)

What needs to change: Macro call that should be transformed by LAMBDA-MATCH

Input:
(lambda-match
  nil)

Output: (defmacro LAMBDA-MATCH ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(c_1
  nil
  nil)

What needs to change: Macro call that should be transformed by C_1

Input:
(c_1
  nil
  nil)

Output:
(defmacro c_1 (&body body)
  `(make-c-dependent
    :code '(without-c-dependency ,@body)
    :inputp nil
    :lazy t
    :value-state :unevaluated
    :rule (c-lambda (without-c-dependency ,@body))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(let-match common-lisp:nil
  common-lisp:nil)

Write a macro that addresses: Macro call that should be transformed by LET-MATCH

Input:
(let-match common-lisp:nil
  common-lisp:nil)

Output:
(defmacro let-match (bindings &body body)
  "Similar to LET, except not only a variable but also a pattern can
be used in BINDINGS."
  `(ematch* ,(mapcar #'cadr bindings)
     (,(mapcar #'car bindings) ,.body)))


Instruction:
Generate a defmacro form that transforms code like this:
(sor nil (progn))

Pattern to recognize: Macro call that should be transformed by SOR

Input: (sor nil (progn))

Output:
(defmacro sor (first &rest rest)
  "Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for
the scope of the rest of the arguments. IT can be set with SETF."
  `(symbolic or ,first ,@rest))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(aand 'lol-gen::some-name)

Problem: Macro call that should be transformed by AAND

Input: (aand 'lol-gen::some-name)

Output: (defmacro AAND ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(c-in-lazy
  nil
  :key
  nil)

What needs to change: Macro call that should be transformed by C-IN-LAZY

Input:
(c-in-lazy
  nil
  :key
  nil)

Output:
(defmacro c-in-lazy (&body body)
  `(c-input (:lazy :once-asked) (progn ,@body)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(defobject nil (progn))

What needs to change: Macro call that should be transformed by DEFOBJECT

Input: (defobject nil (progn))

Output: (defmacro DEFOBJECT ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-yield
  nil
  :key
  nil)

Problem: Macro call that should be transformed by WITH-YIELD

Input:
(with-yield
  nil
  :key
  nil)

Output:
(defmacro with-yield (&body body)
  (let ((point (gensym))
        (current (gensym)))
    `(let (,point ,current)
       (with-call/cc
	 (labels ((yield (&rest values)
		    (setf ,current values)
		    (let/cc k
		      (setf ,point k))))
	   ,@body
	   (setf ,point nil)))
       (gen-lambda ()
	 (cond ((null ,point)
		'generator-stop)
	       (t
		(let ((current ,current))
		  (funcall ,point nil)
		  ;values-handler: see gen-lambda
		  (apply #'values (funcall values-handler current)))))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(on-conflict-do-update nil nil)

What needs to change: Macro call that should be transformed by ON-CONFLICT-DO-UPDATE

Input: (on-conflict-do-update nil nil)

Output:
(defmacro on-conflict-do-update (conflict-target update-set &optional where-condition)
  `(make-clause :on-conflict-do-update
                ,conflict-target
                ,update-set
                ,where-condition))


Instruction:
Define a macro that eliminates this repetitive pattern:
(collect-last 'lol-gen::some-name)

Issue: Macro call that should be transformed by COLLECT-LAST

Input: (collect-last 'lol-gen::some-name)

Output: (defmacro COLLECT-LAST ...)


Instruction:
Generate a defmacro form that transforms code like this:
(atypecase nil
  (progn))

Pattern to recognize: Macro call that should be transformed by ATYPECASE

Input:
(atypecase nil
  (progn))

Output:
(defmacro atypecase (keyform &body cases)
  "Like TYPECASE, except binds the result of the keyform to IT (via LET) for
the scope of the cases."
  `(anaphoric typecase ,keyform ,@cases))


Instruction:
Generate a defmacro form that transforms code like this:
(f_
  nil
  :key
  nil)

Pattern to recognize: Macro call that should be transformed by F_

Input:
(f_
  nil
  :key
  nil)

Output: (defmacro F_ ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(c?+n
  nil
  nil)

Problem: Macro call that should be transformed by C?+N

Input:
(c?+n
  nil
  nil)

Output:
(defmacro c?+n (&body body)
  `(make-c-dependent
    :inputp t
    :code ',body
    :value-state :unevaluated
    :rule (c-lambda ,@body)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(fm-other?! nil nil)

Problem: Macro call that should be transformed by FM-OTHER?!

Input: (fm-other?! nil nil)

Output:
(defmacro fm-other?! (md-name &optional (starting 'self))
   `(fm-find-one ,starting ,(if (consp md-name)
                                         `(list ',(car md-name) ,(cadr md-name))
                                  `',md-name)
     :must-find nil
     :global-search nil))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(dynamic-reprogv nil
    :key
  nil)

Write a macro that addresses: Macro call that should be transformed by DYNAMIC-REPROGV

Input:
(dynamic-reprogv nil
    :key
  nil)

Output: (defmacro DYNAMIC-REPROGV ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(max-of nil
  nil)

Problem: Macro call that should be transformed by MAX-OF

Input:
(max-of nil
  nil)

Output: (defmacro MAX-OF ...)


Instruction:
Generate a defmacro form that transforms code like this:
(<*> nil nil)

Pattern to recognize: Macro call that should be transformed by <*>

Input: (<*> nil nil)

Output:
(defmacro <*> (parser &rest parsers)
  "Combination of parsers yielding all results as a list."
  (let ((offset (gensym "<*>-OFFSET")))
    `(lambda (,offset)
       ,(labels ((recurse (ps i)
                   (if (null ps)
                       `(ok ,i nil)
                       (let ((res  (gensym "<*>-RES"))
                             (next (gensym "<*>-NEXT")))
                         `(multiple-value-bind (,res ,next) (funcall ,(car ps) ,i)
                            (if (failure? ,res)
                                (fail ,next)
                                (fmap (lambda (xs) (cons ,res xs))
                                      ,(recurse (cdr ps) `,next))))))))
          (recurse (cons parser parsers) offset)))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(c-formula nil
  :key
  nil)

Problem: Macro call that should be transformed by C-FORMULA

Input:
(c-formula nil
  :key
  nil)

Output:
(defmacro c-formula ((&rest keys &key lazy &allow-other-keys) &body forms)
  (assert (member lazy '(nil t :once-asked :until-asked :always)))
  `(make-c-dependent
    :code ',forms
    :value-state :unevaluated
    :rule (c-lambda ,@forms)
    ,@keys))


Instruction:
Generate a defmacro form that transforms code like this:
(with-foreign-pointer 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by WITH-FOREIGN-POINTER

Input: (with-foreign-pointer 'lol-gen::some-name)

Output:
(defmacro with-foreign-pointer ((var size &optional size-var) &body body)
  "Bind 'var to 'size bytes of foreign memory during 'body.  The
  pointer in 'var is invalid beyond the dynamic extent of 'body, and
  may be stack-allocated if supported by the implementation.  If
  'size-var is supplied, it will be bound to 'size during 'body."
  (unless size-var
    (setf size-var (gensym (symbol-name '#:size))))
  ;; If the size is constant we can stack-allocate.
  (cond ((constantp size)
         (let ((alien-var (gensym (symbol-name '#:alien))))
           `(with-alien ((,alien-var (array (unsigned 8) ,(eval size))))
             (let ((,size-var ,size)
                   (,var (alien-sap ,alien-var)))
               (declare (ignorable ,size-var))
               ,@body))))
        (t
         `(let ((,size-var ,size))
            (alien:with-bytes (,var ,size-var)
              ,@body)))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(f-zerop nil)

Write a macro that addresses: Macro call that should be transformed by F-ZEROP

Input: (f-zerop nil)

Output:
(defmacro f-zerop (key &rest body)
  `(with-synapse ,key (prior-fire-value)
     (let ((new-basis (progn ,@body)))
       (values new-basis (if (xor prior-fire-value (zerop new-basis))
                             (progn
                               (setf prior-fire-value (zerop new-basis))
                               :propagate)
                           :no-propagate)))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(acase nil)

Write a macro that addresses: Macro call that should be transformed by ACASE

Input: (acase nil)

Output:
(defmacro acase (keyform &body cases)
  "Like CASE, except binds the result of the keyform to IT (via LET) for the
scope of the cases."
  `(anaphoric case ,keyform ,@cases))


Instruction:
Generate a defmacro form that transforms code like this:
(with-mapping-appender 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by WITH-MAPPING-APPENDER

Input: (with-mapping-appender 'lol-gen::some-name)

Output: (defmacro WITH-MAPPING-APPENDER ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(xor)

Write a macro that addresses: Macro call that should be transformed by XOR

Input: (xor)

Output:
(defmacro xor (&rest args)
  "Evaluates the ARGS one at a time. If more than one is T,
   evaluation stops and NIL is returned. If exactly one arg is T,
   that value is returned."
  (let ((state (gensym "XOR-state-"))
        (block-name (gensym "XOR-block-"))
        (arg-temp (gensym "XOR-arg-temp-")))
    `(let (,state
           ,arg-temp)
       (block ,block-name
         ,@(loop
              :for arg :in args
              :collect `(setf ,arg-temp ,arg)
              :collect `(when ,arg-temp
                          ;; arg is T, this can change the state
                          (if ,state
                              ;; a second T value, return NIL
                              (return-from ,block-name nil)
                              ;; a first T, swap the state
                              (setf ,state ,arg-temp))))
         (return-from ,block-name ,state)))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(f-zerop nil (progn))

Problem: Macro call that should be transformed by F-ZEROP

Input: (f-zerop nil (progn))

Output:
(defmacro f-zerop (key &rest body)
  `(with-synapse ,key (prior-fire-value)
     (let ((new-basis (progn ,@body)))
       (values new-basis (if (xor prior-fire-value (zerop new-basis))
                             (progn
                               (setf prior-fire-value (zerop new-basis))
                               :propagate)
                           :no-propagate)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(nconcf nil (progn))

What needs to change: Macro call that should be transformed by NCONCF

Input: (nconcf nil (progn))

Output: (defmacro NCONCF ...)


Instruction:
Generate a defmacro form that transforms code like this:
(case-using nil
    (progn))

Pattern to recognize: Macro call that should be transformed by CASE-USING

Input:
(case-using nil
    (progn))

Output:
(defmacro case-using (pred keyform &body clauses)
  "ISLISP's case-using.

     (case-using #'eql x ...)
     ≡ (case x ...).

Note that, no matter the predicate, the keys are not evaluated. (But
see `selector'.)

The PRED form is evaluated.

When PRED is invoked, KEYFORM is its first argument. You can use
`flip' if you want the arguments passed the other way around. For
example, to dispatch on potential elements of a list:

    (case-using list (flip #'member)
      (:item1 ...))

This version supports both single-item clauses (x ...) and
multiple-item clauses ((x y) ...), as well as (t ...) or (otherwise
...) for the default clause."
  (case (extract-function-name pred)
    (eql
     `(case ,keyform
        ,@clauses))
    ;; TODO Check that this isn't rebound in the environment. (Not a
    ;; concern on SBCL as the package is locked there.)
    (string=
     `(string-case ,keyform
        ,@clauses))
    (t `(case-using-aux ,pred ,keyform
          ,@clauses))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(defunion nil)

Issue: Macro call that should be transformed by DEFUNION

Input: (defunion nil)

Output:
(defmacro defunion (union &body variants)
  "Define an algebraic data type.

Each expression in VARIANTS is either a symbol \(in which case it
defines a unit type, as with `defunit') or a list \(in which case it
defines a read-only structure, as with `defconstructor').

UNION is defined as a type equivalent to the disjunction of all the
member types. A class is also defined, with the same name, but with
angle brackets around it."
  (let* ((docstring (and (stringp (first variants))
                         (pop variants)))
         (ctors (remove-if-not #'listp variants))
         (units (remove-if-not #'atom variants))
         (types (append units (mapcar #'first ctors)))
         (super (symbolicate '< union '>)))
    ;; CCL (and maybe other lisps) evaluates `(:include)' options at
    ;; macroexpansion time and does some environment augmenting and checking
    ;; that fails to account for our `env-super' trick.
    ;; So define the abstract base struct via a `progn' at the toplevel.
    `(progn
       (eval-when (:compile-toplevel :load-toplevel :execute)
         (defstruct (,super
                     (:constructor nil)
                     (:copier nil)
                     (:predicate nil)
                     (:include %read-only-struct))
           ,@(unsplice docstring)))
       ;; NB The declarations are not currently used, due to an SBCL bug.
       (locally (declare #+sbcl (sb-ext:disable-package-locks %union))
         (symbol-macrolet ((serapeum/unlocked:%union ,super))
           (declare #+sbcl (sb-ext:enable-package-locks %union))
           (deftype ,union ()
             ,@(unsplice docstring)
             '(or ,@types))
           ,@(loop for type in units
                   collect `(defunit ,type))
           ,@(loop for (type . slots) in ctors
                   collect `(defconstructor ,type ,@slots))
           (declaim-freeze-type ,super)
           ',union)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(f nil
  nil)

Issue: Macro call that should be transformed by F

Input:
(f nil
  nil)

Output: (defmacro F ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(restart-bind nil
  :key
  nil)

Issue: Macro call that should be transformed by RESTART-BIND

Input:
(restart-bind nil
  :key
  nil)

Output: (defmacro RESTART-BIND ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(collect-sum nil (progn))

What needs to change: Macro call that should be transformed by COLLECT-SUM

Input: (collect-sum nil (progn))

Output: (defmacro COLLECT-SUM ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(fn nil
    (progn))

What needs to change: Macro call that should be transformed by FN

Input:
(fn nil
    (progn))

Output: (defmacro FN ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-unique-names nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by WITH-UNIQUE-NAMES

Input:
(with-unique-names nil
  (progn))

Output: (defmacro WITH-UNIQUE-NAMES ...)


Instruction:
Generate a defmacro form that transforms code like this:
(define-test+run-interactively nil
  (progn))

Pattern to recognize: Macro call that should be transformed by DEFINE-TEST+RUN-INTERACTIVELY

Input:
(define-test+run-interactively nil
  (progn))

Output:
(defmacro define-test+run-interactively (name &body args-and-body)
  `(progn (define-test ,name ,@args-and-body)
          (eval-when (:execute)
            (values ',name (test ',name :report 'interactive)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(f nil
  (progn))

Issue: Macro call that should be transformed by F

Input:
(f nil
  (progn))

Output: (defmacro F ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(specializing nil
    nil)

Problem: Macro call that should be transformed by SPECIALIZING

Input:
(specializing nil
    nil)

Output: (defmacro SPECIALIZING ...)


Instruction:
Generate a defmacro form that transforms code like this:
(ok 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by OK

Input: (ok 'lol-gen::some-name)

Output:
(defmacro ok (test &optional desc)
  (with-gensyms (duration result)
    (once-only (test desc)
      `(with-catching-errors (:expected T :description ,desc)
         (with-duration ((,duration ,result) ,test)
           (test ,result t ,desc
                 :duration ,duration
                 :test-fn (lambda (x y)
                            (eq (not (null x)) y))
                 :got-form ,test))))))


Instruction:
Generate a defmacro form that transforms code like this:
(cmatch common-lisp:nil)

Pattern to recognize: Macro call that should be transformed by CMATCH

Input: (cmatch common-lisp:nil)

Output:
(defmacro cmatch (what &body clauses)
  #.+match-doc+
  (with-gensyms (otherwise)
    `(match2 ,what
       ,@clauses
       (,otherwise (cerror "continue" 'match-error :pattern ',clauses :values (list ,otherwise))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(define-constant nil nil)

What needs to change: Macro call that should be transformed by DEFINE-CONSTANT

Input: (define-constant nil nil)

Output:
(defmacro define-constant (name initial-value &key (test ''eql) documentation)
  "Ensures that the global variable named by NAME is a constant with a value
that is equal under TEST to the result of evaluating INITIAL-VALUE. TEST is a
/function designator/ that defaults to EQL. If DOCUMENTATION is given, it
becomes the documentation string of the constant.

Signals an error if NAME is already a bound non-constant variable.

Signals an error if NAME is already a constant variable whose value is not
equal under TEST to result of evaluating INITIAL-VALUE."
  `(defconstant ,name (%reevaluate-constant ',name ,initial-value ,test)
     ,@(when documentation `(,documentation))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(nor 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by NOR

Input: (nor 'lol-gen::some-name)

Output:
(defmacro nor (&rest forms)
  "Equivalent to (not (or ...)).

From Arc."
  (if (null forms) t
      (if (null (rest forms))
          `(not ,(first forms))
          `(if ,(first forms)
               nil
               (nor ,@(rest forms))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(define-constant nil (progn))

Write a macro that addresses: Macro call that should be transformed by DEFINE-CONSTANT

Input: (define-constant nil (progn))

Output:
(defmacro define-constant (name initial-value &key (test ''eql) documentation)
  "Ensures that the global variable named by NAME is a constant with a value
that is equal under TEST to the result of evaluating INITIAL-VALUE. TEST is a
/function designator/ that defaults to EQL. If DOCUMENTATION is given, it
becomes the documentation string of the constant.

Signals an error if NAME is already a bound non-constant variable.

Signals an error if NAME is already a constant variable whose value is not
equal under TEST to result of evaluating INITIAL-VALUE."
  `(defconstant ,name (%reevaluate-constant ',name ,initial-value ,test)
     ,@(when documentation `(,documentation))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(inner-join 'lol-gen::some-name)

Issue: Macro call that should be transformed by INNER-JOIN

Input: (inner-join 'lol-gen::some-name)

Output:
(defmacro inner-join (table &key on using)
  `(join ,table :kind :inner :on ,on :using ,using))


Instruction:
Define a macro that eliminates this repetitive pattern:
(defobject-amendment nil)

Issue: Macro call that should be transformed by DEFOBJECT-AMENDMENT

Input: (defobject-amendment nil)

Output: (defmacro DEFOBJECT-AMENDMENT ...)


Instruction:
Generate a defmacro form that transforms code like this:
(keep-bops nil :key nil)

Pattern to recognize: Macro call that should be transformed by KEEP-BOPS

Input: (keep-bops nil :key nil)

Output: (defmacro KEEP-BOPS ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-yield
  nil
  nil)

Write a macro that addresses: Macro call that should be transformed by WITH-YIELD

Input:
(with-yield
  nil
  nil)

Output:
(defmacro with-yield (&body body)
  (let ((point (gensym))
        (current (gensym)))
    `(let (,point ,current)
       (with-call/cc
	 (labels ((yield (&rest values)
		    (setf ,current values)
		    (let/cc k
		      (setf ,point k))))
	   ,@body
	   (setf ,point nil)))
       (gen-lambda ()
	 (cond ((null ,point)
		'generator-stop)
	       (t
		(let ((current ,current))
		  (funcall ,point nil)
		  ;values-handler: see gen-lambda
		  (apply #'values (funcall values-handler current)))))))))


Instruction:
Generate a defmacro form that transforms code like this:
(letrec* nil
  nil)

Pattern to recognize: Macro call that should be transformed by LETREC*

Input:
(letrec* nil
  nil)

Output:
(defmacro letrec* ((&rest bindings) &body body)
  "Like LETREC, but the bindings are evaluated in order.
See Waddell et al., *Fixing Letrec* for motivation.

Cf. `fbindrec*'."
  `(letrec-with setq ,bindings
     ,@body))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(if-not-let nil
  :key
  nil)

Problem: Macro call that should be transformed by IF-NOT-LET

Input:
(if-not-let nil
  :key
  nil)

Output:
(defmacro if-not-let (bindings &body (then-form &optional else-form))
  "Creates new variable bindings, and conditionally executes either
THEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL.
BINDINGS must be either single binding of the form:
 (variable initial-form)
or a list of bindings of the form:
 ((variable-1 initial-form-1)
  (variable-2 initial-form-2)
  ...
  (variable-n initial-form-n))
All initial-forms are executed sequentially in the specified order. Then all
the variables are bound to the corresponding values.
If one of the variables was bound to NIL, the THEN-FORM is executed with the
bindings in effect, otherwise the ELSE-FORM is executed with the bindings in
effect.
Adapted from Alexandria if-let."
  (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                           (list bindings)
                           bindings))
         (variables (mapcar #'car binding-list)))
    `(let ,binding-list
       (if-not (and ,@variables)
	       ,then-form
	       ,else-form))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(make nil nil)

What needs to change: Macro call that should be transformed by MAKE

Input: (make nil nil)

Output: (defmacro MAKE ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(c-envalue
  nil
  :key
  nil)

Write a macro that addresses: Macro call that should be transformed by C-ENVALUE

Input:
(c-envalue
  nil
  :key
  nil)

Output:
(defmacro c-envalue (&body body)
  `(make-c-envaluer
    :envalue-rule (c-lambda ,@body)))


Instruction:
Generate a defmacro form that transforms code like this:
(defdata nil
  (progn))

Pattern to recognize: Macro call that should be transformed by DEFDATA

Input:
(defdata nil
  (progn))

Output:
(defmacro defdata (adt-name &body constructors)
  "Define a new ADT. ADT-name has the following grammar:

ADT-NAME := <symbol>
          | (<symbol> <options>*)

There is no difference between specifying it as a symbol or as a
singleton list. There are two possible options, specified as a
property list:

    * :MUTABLE {T, NIL} (default: NIL): Specifies whether the fields
      of the type are mutable, allowing the use of SET-DATA.

    * :INCLUDE <adt-type>: Specifies whether another defined ADT
      should be inherited.

Constructors is a list of clauses with the following grammar:

<clause> := <symbol>
          | (<symbol> <type-specifier>*)

Each clause defines a constructor for the ADT. Nullary constructors
will define constants and all other constructors will define
functions."
  ;; Do some extreme sanity checking.
  (assert
   (or
    ;; Must be a symbol, or...
    (symbolp adt-name)
    (and
     ;; a list that is...
     (listp adt-name)
     ;; non-empty
     (not (null adt-name))
     ;; whose first element is a symbol (the name of the adt)
     (symbolp (first adt-name))
     ;; and the rest is a property list
     (property-list-p (rest adt-name))))
   (adt-name)
   "ADT-NAME must either be a symbol, a singleton list with the ADT ~
      name as a symbol, or a list of two elements with the ADT name ~
      and :MUTABLE respectively. Given ~S."
   adt-name)
  (let ((valid-options (list ':mutable ':include)))
    (when (and (listp adt-name) (= (mod (length (rest adt-name)) 2) 0))
      (loop for opt in (rest adt-name) by #'cddr do
	   (when (not (member opt valid-options))
	     (error "Option ~A is not valid, valid options are member of ~A." opt valid-options)))))

  (let ((adt-name (ensure-car adt-name))
        (mutable? (and (listp adt-name)
                       (getf (rest adt-name) ':mutable)
                       t))
        (include (or (and (listp adt-name)
                          (getf (rest adt-name) ':include))
                     'algebraic-data-type))
        (object (gensym "OBJECT-"))
        (stream (gensym "STREAM-"))
        (depth (gensym "DEPTH-"))
        (env (gensym "ENVIRONMENT-"))
        (documentation
          (when (stringp (car constructors))
            (pop constructors))))

    ;; Sanity check that INCLUDE is a proper algebraic data type.
    (assert (algebraic-data-type-p include)
            ()
            "When defining the algebraic data type ~S, the :INCLUDE option ~
             was specified with ~S, which is not another algebraic data ~
             type."
            adt-name
            include)

    ;; Add constructors and their arity to the database.
    (flet ((constructor-and-arity (ctor)
             (if (listp ctor)
                 (list (first ctor) (length (rest ctor)))
                 (list ctor 0))))
      (set-constructors adt-name (append (get-constructors include)
                                         (mapcar #'constructor-and-arity constructors))))

    (flet ((make-printer (name &optional (nfields 0))
             "Make a printer function for the structs."
             `(lambda (,object ,stream ,depth)
                (declare (ignore ,depth)
                         (ignorable ,object))
                ;; We don't check *PRINT-READABLY* because these can
                ;; be readably printed always, provided the arguments
                ;; can be printed readably.
                ;;
                ;; However, we do respect a convenience option
                ;; *PRINT-ADT-READABLY* in case someone finds the
                ;; printing of the #. to be annoying.
                (when *print-adt-readably*
                  (write-string "#." ,stream))
                ,(when (plusp nfields)
                   `(write-char #\( ,stream))
                (prin1 ',name ,stream)
                ,@(when (plusp nfields)
                    (loop :for i :below nfields
                          :append (list
                                   `(write-char #\Space ,stream)
                                   `(prin1 (,(field name i) ,object)
                                           ,stream))))
                ,(when (plusp nfields)
                   `(write-char #\) ,stream)))))
      ;; Define everything.
      (let ((component-documentation
             ;; Force the adt-name symbol to print with a package
             ;; prefix
             (let ((*package* (find-package :keyword)))
               (format nil "A component of ADT ~S" adt-name))))
        `(eval-when (:compile-toplevel :load-toplevel :execute)
           ;; Define the data type.
           (defstruct (,adt-name (:constructor nil)
                                 (:copier nil)
                                 (:predicate nil)
                                 (:include ,include))
             ,@(unsplice documentation))

           ;; Define each of the field constructors.
           ,@(loop :for ctor :in (unwrap-singletons constructors)
                   :collect
                   (etypecase ctor
                     ;; Nullary constructor
                     (symbol `(progn
                                (eval-when (:compile-toplevel :load-toplevel :execute)
                                  (defstruct
                                      (,ctor
                                       (:include ,adt-name)
                                       (:constructor ,(internal ctor))
                                       (:copier nil)
                                       (:predicate nil)
                                       (:print-function ,(make-printer ctor)))
                                    ,component-documentation))
                                #+sbcl (declaim (sb-ext:freeze-type ,ctor))
                                (defmethod make-load-form ((,object ,ctor) &optional ,env)
                                  (make-load-form-saving-slots ,object
                                                               :slot-names nil
                                                               :environment ,env))
                                (define-constant ,ctor (,(internal ctor))
                                  ,component-documentation)
                                (fmakunbound ',(internal ctor))))

                     ;; N-ary constructors
                     (list (let* ((ctor-name (first ctor))
                                  (field-types (rest ctor))
                                  (field-names (gen-names (length field-types))))
                             `(progn
                                (defstruct (,ctor-name
                                            (:include ,adt-name)
                                            (:constructor ,ctor-name (,@field-names))
                                            (:conc-name ,ctor-name)
                                            (:copier nil)
                                            (:predicate nil)
                                            (:print-function
                                             ,(make-printer ctor-name
                                                            (length field-names))))
                                  ,component-documentation
                                  ,@(mapcar (lambda (name type)
                                              `(,name (error "Unspecified field.")
                                                      :type ,type
                                                      ,@(if mutable?
                                                            nil
                                                            '(:read-only t))))
                                     field-names
                                     field-types))
                                #+sbcl (declaim (sb-ext:freeze-type ,ctor-name))
                                (defmethod make-load-form ((,object ,ctor-name) &optional ,env)
                                  (make-load-form-saving-slots ,object
                                                               :slot-names ',field-names
                                                               :environment ,env)))))))
           ;; Return the type name
           ',adt-name)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(defparam nil nil)

What needs to change: Macro call that should be transformed by DEFPARAM

Input: (defparam nil nil)

Output: (defmacro DEFPARAM ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(either
  nil
  :key
  nil)

Issue: Macro call that should be transformed by EITHER

Input:
(either
  nil
  :key
  nil)

Output: (defmacro EITHER ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(labels* nil
  (progn))

Problem: Macro call that should be transformed by LABELS*

Input:
(labels* nil
  (progn))

Output: (defmacro LABELS* ...)


Instruction:
Generate a defmacro form that transforms code like this:
(lambda* nil
  (progn))

Pattern to recognize: Macro call that should be transformed by LAMBDA*

Input:
(lambda* nil
  (progn))

Output: (defmacro LAMBDA* ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(fnn nil nil)

Write a macro that addresses: Macro call that should be transformed by FNN

Input: (fnn nil nil)

Output: (defmacro FNN ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(and nil :key nil)

Problem: Macro call that should be transformed by AND

Input: (and nil :key nil)

Output: (defmacro AND ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(declaration common-lisp:nil)

Problem: Macro call that should be transformed by DECLARATION

Input: (declaration common-lisp:nil)

Output: (defmacro DECLARATION ...)


Instruction:
Generate a defmacro form that transforms code like this:
(export-always nil (progn))

Pattern to recognize: Macro call that should be transformed by EXPORT-ALWAYS

Input: (export-always nil (progn))

Output:
(defmacro export-always (symbols &optional (package nil package-supplied?))
  "Like `export', but also evaluated at compile time."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (export ,symbols ,@(and package-supplied? (list package)))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(as-> nil :key nil)

Problem: Macro call that should be transformed by AS->

Input: (as-> nil :key nil)

Output: (defmacro AS-> ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(appendf nil :key nil)

Write a macro that addresses: Macro call that should be transformed by APPENDF

Input: (appendf nil :key nil)

Output: (defmacro APPENDF ...)


Instruction:
Generate a defmacro form that transforms code like this:
(with-decoder-simple-list-semantics
  nil
  nil)

Pattern to recognize: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS

Input:
(with-decoder-simple-list-semantics
  nil
  nil)

Output:
(defmacro with-decoder-simple-list-semantics (&body body)
  "Execute BODY in a dynamic environement where the decoder semantics
is such as set by SET-DECODER-SIMPLE-LIST-SEMANTICS."
  `(with-shadowed-custom-vars
     (set-decoder-simple-list-semantics)
     ,@body))