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

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

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

Output:
(defmacro dolines ((line src &optional result) &body body)
  "Iterate over each LINE in SRC (a stream or path to a file) as in DOLIST."
  (let ((in (gensym)))
    (once-only (src)
      `(if (streamp ,src)
           (loop :for ,line := (read-line ,src nil nil) :while ,line :do
             (progn ,@body)
                 :finally (return ,result))
           (with-open-file (,in ,src)
             (loop :for ,line := (read-line ,in nil nil) :while ,line :do
               (progn ,@body)
                   :finally (return ,result)))))))


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

Problem: Macro call that should be transformed by CALLBACK

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

Output:
(defmacro callback (name)
  `(%callback ',name))


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

Problem: Macro call that should be transformed by SETF

Input: (setf nil nil)

Output: (defmacro SETF ...)


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

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

Input:
(define-type-dispatch nil
    (progn))

Output: (defmacro DEFINE-TYPE-DISPATCH ...)


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

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

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

Output:
(defmacro fm-collect (md-name &key (must-find t))
   `(fm-find-all self ',md-name :must-find ,must-find))


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

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

Input: (bind nil)

Output:
(defmacro bind ((&rest bindings) &body body)
  "Bind variables from BINDINGS to be active inside BODY, as if by LET*,
combined with MULTIPLE-VALUE-BIND, DESTRUCTURING-BIND and other -bind forms,
depending on the type of the first argument."
  (let ((rez body))
    (dolist (binding (reverse bindings))
      (setf rez `((,@(funcall #'expand-binding binding rez)))))
    (first rez)))


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

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

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

Output: (defmacro PROG1 ...)


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

Problem: Macro call that should be transformed by MINF

Input: (minf nil)

Output: (defmacro MINF ...)


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

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

Input: (.< 'lol-gen::some-name)

Output:
(defmacro .< (cl:&rest items)
  "Right associative compose operator. Creates a new functions that will run the
functions right to left when applied. This is the same as the `nest` macro without supplying
the value. The composition is thus the same order as `compose`.

`(.< f g h)` creates the function `(fn (x) (f (g (h x))))`."
  (alexandria:with-gensyms (x)
    `(fn (,x)
       (nest ,@items ,x))))


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

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

Input:
(-<>
  nil
  nil)

Output: (defmacro -<> ...)


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

Write a macro that addresses: Macro call that should be transformed by STRING-CASE

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

Output: (defmacro STRING-CASE ...)


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

Problem: Macro call that should be transformed by ECASE-USING

Input:
(ecase-using nil
    nil)

Output:
(defmacro ecase-using (pred keyform &body clauses)
  "Exhaustive variant of `case-using'."
  (once-only (keyform)
    `(case-using ,pred ,keyform
       ,@clauses
       (otherwise
        (error "~s fell through ~a with ~s"
               ,keyform
               'ecase-using
               ',pred)))))


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

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

Input: (when nil (progn))

Output: (defmacro WHEN ...)


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

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

Input: (deletef nil (progn))

Output: (defmacro DELETEF ...)


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

Write a macro that addresses: Macro call that should be transformed by SELECT-DAO

Input: (select-dao nil)

Output:
(defmacro select-dao (type &optional (test t) &rest ordering)
  "Select DAO objects for the rows in the associated table for which the given
test (either an S-SQL expression or a string) holds. When sorting arguments
are given, which can also be S-SQL forms or strings, these are used to sort
the result.

(Note that, if you want to sort, you have to pass the test argument.)

    (select-dao 'user (:> 'score 10000) 'name)"

  `(query-dao% ,type (sql ,(generate-dao-query type test ordering))
               (dao-row-reader (find-class ,type))))


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

Pattern to recognize: Macro call that should be transformed by TREE-ECASE

Input:
(tree-ecase nil
  (progn))

Output: (defmacro TREE-ECASE ...)


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

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

Input:
(match* common-lisp:nil
  (common-lisp:progn))

Output:
(defmacro match* (whats &body clauses)
  #.+match*-doc+
  `(match2* ,whats
     ,@clauses
     (_ nil)))


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

Issue: Macro call that should be transformed by AAND

Input: (aand nil (progn))

Output:
(defmacro aand (first &rest rest)
  "Like AND, except binds the first argument to IT (via LET) for the
scope of the rest of the arguments."
  `(anaphoric and ,first ,@rest))


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

Problem: Macro call that should be transformed by WITH-TOOK-USEC

Input: (with-took-usec nil)

Output:
(defmacro with-took-usec (var &body body)
  (let ((before (gensym "BEFORE")))
    `(let ((,before (get-internal-real-time)))
       (multiple-value-prog1 (progn ,@body)
         (setf ,var (ceiling
                      (* (- (get-internal-real-time) ,before)
                         #.(/ 1000000 internal-time-units-per-second))))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(def-launched-iter nil
    :key
  nil)

What needs to change: Macro call that should be transformed by DEF-LAUNCHED-ITER

Input:
(def-launched-iter nil
    :key
  nil)

Output: (defmacro DEF-LAUNCHED-ITER ...)


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

Problem: Macro call that should be transformed by RETURN

Input: (return)

Output: (defmacro RETURN ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-dispatch nil
    nil)

Issue: Macro call that should be transformed by DEFINE-DISPATCH

Input:
(define-dispatch nil
    nil)

Output:
(defmacro define-dispatch (name lambda-list &body body)
  "the lambda list should accept two arguments:
the list of arguments given by the current method call.
the specific hooks (as named or unamed functions) for the qualified method (that we will be dispatching from).

you should then use the arguments to dispatch the specific hooks as you wish in the body.
if the body returns a result, by default the method will also return that result, this can be overriden with finalize-dispatch-method.

See finalize-dispatch-method
See dispatch"
  `(let ((new-dispatch (make-dispatcher (lambda ,lambda-list ,@body))))
     (setf (gethash ',name *dispatch-table*)
           new-dispatch)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(declare-deprecated-operators nil (progn))

What needs to change: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS

Input: (declare-deprecated-operators nil (progn))

Output: (defmacro DECLARE-DEPRECATED-OPERATORS ...)


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

Problem: Macro call that should be transformed by ENSURE2

Input:
(ensure2 nil
  nil)

Output:
(defmacro ensure2 (place &body newval &environment env)
  "Like `ensure', but specifically for accessors that return a second
value like `gethash'."
  (multiple-value-bind (vars vals stores setter getter)
      (get-setf-expansion place env)
    (with-gensyms (old presentp)
      `(let* ,(mapcar #'list vars vals)
         (multiple-value-bind (,old ,presentp)
             ,getter
           (if ,presentp
               ,old
               (multiple-value-bind ,stores
                   (progn ,@newval)
                 ,setter)))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(do-iter-values nil
  (progn))

Issue: Macro call that should be transformed by DO-ITER-VALUES

Input:
(do-iter-values nil
  (progn))

Output:
(defmacro do-iter-values ((&rest iters) &body forms)
  "Iterate over the remaining elements of a sequence pointed to by static iterators.

   Evaluate FORMS at each iteration, for each remaining element, until
   one of the iterators reaches the end of the sequence.

   NOTE: May only be used inside a WITH-ITERATORS form.

   ITERS:

     List of bindings. Each element is of the form (PATTERN ITER),
     interpreted as if to WITH-ITER-VALUE, where PATTERN is a binding
     pattern, for the binding to the sequence element value, and ITER
     is a static iterator identifier symbol, introduced in a parent
     WITH-ITERATORS form.

   FORMS

     List of forms evaluated for each remaining element in the
     sequences pointed to by the static iterators.

     At each evaluation the next element of each sequence, pointed by
     each ITER in ITERS, is bound to the variable(s) specified by the
     corresponding PATTERN. After which the iterators are advanced to
     the next elements.

   If one of the iterators has reached the end of its sequence, a
   non-local jump outside the enclosing WITH-ITERATORS form is
   performed, i.e. any forms following this form, within the enclosing
   WITH-ITERATORS form, will not be evaluated."

  (with-gensyms (start)
    `(tagbody
        ,start
        (with-iter-values ,iters ,@forms)
        (go ,start))))


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

What needs to change: 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:
(defpattern common-lisp:nil
    (common-lisp:progn))

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

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

Output:
(defmacro defpattern (name args &body body)
  "Adds a new derived pattern.
The default value of &optional arguments are '_, instead of nil."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (symbol-pattern ',name)
           #+sbcl
           (sb-int:named-lambda ',name ,(process-lambda-args args) ,@body)
           #-sbcl
           (lambda ,(process-lambda-args args) ,@body))
     ,@(when (stringp (first body))
         ;; lisp-namespace
         `((setf (documentation ',name 'pattern)
                 ,(let ((*print-pretty* t))
                    #-clisp
                    (format nil "~<Lambda-List: ~s~
                                 ~:@_~<  ~@;~a~:>~
                                 ~:@_Defined in ~a~
                               ~:>"
                            (list args (list (first body)) *compile-file-pathname*))
                    #+clisp
                    (format nil "Lambda-List: ~s~%~a"
                            args (first body))))))))


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:
Generate a defmacro form that transforms code like this:
(dispatch nil :key nil)

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

Input: (dispatch nil :key nil)

Output:
(defmacro dispatch (generic-function qualifier specialized-lambda-list)
  "dispatch the hooks using the default dispatcher for the given qualified specific method.

See define-dispatch
See dispatch-function
See set-dispatch-for-qualifier"
  (destructure-specialized-lambda-list descriptive-lambda-list vanilla-lambda-list type-list specialized-lambda-list
     `(funcall (dispatch-function (dispatch-for-qualifier ',qualifier))
               (list ,@vanilla-lambda-list)
               (mapcar #'hook-name
                       (specific-hooks-for-generic ',type-list ',generic-function ',qualifier)))))


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

Problem: Macro call that should be transformed by IMPLIES

Input: (implies nil (progn))

Output:
(defmacro implies (condition consequent)
  "A boolean operator that evaluates to the value of CONSEQUENT if CONDITION is
   true, and otherwise evaluates to T. This isn't particularly specific to Quid
   Pro Quo, but it is a useful logical operator for contracts."
  `(if ,condition ,consequent t))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(enable-quasi-quoted-string-syntax)

What needs to change: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-SYNTAX

Input: (enable-quasi-quoted-string-syntax)

Output: (defmacro ENABLE-QUASI-QUOTED-STRING-SYNTAX ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(eval-when-execute
  common-lisp:nil
  :key
  common-lisp:nil)

Issue: Macro call that should be transformed by EVAL-WHEN-EXECUTE

Input:
(eval-when-execute
  common-lisp:nil
  :key
  common-lisp:nil)

Output: (defmacro EVAL-WHEN-EXECUTE ...)


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

Write a macro that addresses: Macro call that should be transformed by COUNT-OF

Input:
(count-of nil
  :key
  nil)

Output: (defmacro COUNT-OF ...)


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 -> ...)


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

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

Input: (is-true nil (progn))

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:
Write a Common Lisp macro to handle this code pattern:
(declaim nil
         :key
         nil)

Problem: Macro call that should be transformed by DECLAIM

Input:
(declaim nil
         :key
         nil)

Output: (defmacro DECLAIM ...)


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

Issue: Macro call that should be transformed by ECOND

Input: (econd nil (progn))

Output:
(defmacro econd (&rest clauses)
  "Like `cond', but signal an error of type `econd-failure' if no
clause succeeds."
  (let ((test-count (length clauses)))
    `(cond ,@clauses
           ;; SBCL will silently eliminate this branch if it is
           ;; unreachable.
           (t (error 'econd-failure :test-count ',test-count)))))


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

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

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

Output: (defmacro INLINE ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-custom-decoder-level nil
  (progn))

What needs to change: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL

Input:
(with-custom-decoder-level nil
  (progn))

Output:
(defmacro with-custom-decoder-level ((&rest customizations) &body body)
  "Execute BODY in a dynamic environment such that, when nested
structures are decoded, the outermost level is decoded with the given
custom handlers (CUSTOMIZATIONS) whereas inner levels are decoded in
the usual way."
  `(let ((current-decoder
          (current-decoder
           ,@(loop for (key value) on customizations by #'cddr
                if (eq key :internal-decoder)
                  do (error "~S ~S customization is meaningless in ~
                             the context of WITH-CUSTOM-DECODER-LEVEL."
                            key value)
                else collect key))))
     (bind-custom-vars (:internal-decoder current-decoder ,@customizations)
       ,@body)))


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

Issue: Macro call that should be transformed by SCTYPECASE

Input: (sctypecase nil)

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


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

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

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

Output:
(defmacro econd (&rest clauses)
  "Like `cond', but signal an error of type `econd-failure' if no
clause succeeds."
  (let ((test-count (length clauses)))
    `(cond ,@clauses
           ;; SBCL will silently eliminate this branch if it is
           ;; unreachable.
           (t (error 'econd-failure :test-count ',test-count)))))


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

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

Input: (alt nil :key nil)

Output:
(defmacro alt (parser &rest parsers)
  "Accept the results of the first parser from a group to succeed."
  (let ((offset (gensym "ALT-OFFSET")))
    `(lambda (,offset)
       ,(labels ((recurse (ps furthest)
                   (if (null ps)
                       `(fail ,furthest)
                       (let ((res  (gensym "ALT-RES"))
                             (next (gensym "ALT-NEXT")))
                         `(multiple-value-bind (,res ,next) (funcall ,(car ps) ,offset)
                            (if (ok? ,res)
                                (values ,res ,next)
                                ,(recurse (cdr ps) `(max ,next ,furthest))))))))
          (recurse (cons parser parsers) offset)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(multiple-value-ematch common-lisp:nil
  (common-lisp:progn))

Issue: Macro call that should be transformed by MULTIPLE-VALUE-EMATCH

Input:
(multiple-value-ematch common-lisp:nil
  (common-lisp:progn))

Output:
(defmacro multiple-value-ematch (values-form &body clauses)
  #.+multiple-value-match-doc+
  (call-with-mvb-temp-vars
   clauses
   (lambda (clauses temps)
     `(multiple-value-bind ,temps ,values-form
        (match* ,temps
          ,@clauses
          (,temps
           (error 'match-error :pattern ',clauses :values (list ,@temps))))))))


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

Issue: Macro call that should be transformed by IS-TRACED$METHOD

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

Output: (defmacro IS-TRACED$METHOD ...)


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

Issue: Macro call that should be transformed by WITH

Input: (with)

Output: (defmacro WITH ...)


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

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

Input:
(ensure nil
  (progn))

Output:
(defmacro ensure (place &body newval
                        &environment env)
  "Essentially (or place (setf place newval)).

PLACE is treated as unbound if it returns `nil', signals
`unbound-slot', or signals `unbound-variable'.

Note that ENSURE is `setf'-able, so you can do things like
     (incf (ensure x 0))

Cf. `ensure2'."
  (multiple-value-bind (vars vals stores setter getter)
      (get-setf-expansion place env)
    `(let* ,(mapcar #'list vars vals)
       (or (ignore-some-conditions (unbound-slot unbound-variable)
             ,getter)
           (multiple-value-bind ,stores
               (progn ,@newval)
             (when ,(first stores)
               ,setter))))))


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

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

Input: (with-special-initargs nil)

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


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

Write a macro that addresses: Macro call that should be transformed by FORM-ATTRIBUTE

Input: (form-attribute nil :key nil)

Output: (defmacro FORM-ATTRIBUTE ...)


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

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

Input: (and nil (progn))

Output: (defmacro AND ...)


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

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

Input: (defpackage nil (progn))

Output: (defmacro DEFPACKAGE ...)


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

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

Input: (make* nil nil)

Output: (defmacro MAKE* ...)


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

Problem: Macro call that should be transformed by FIELDS

Input: (fields nil (progn))

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


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

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

Input: (prog* () :key nil)

Output: (defmacro PROG* ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(ignorable common-lisp:nil
  :key
  common-lisp:nil)

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

Input:
(ignorable common-lisp:nil
  :key
  common-lisp:nil)

Output: (defmacro IGNORABLE ...)


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

Problem: Macro call that should be transformed by DEFGENERIC*

Input:
(defgeneric* nil
    nil)

Output: (defmacro DEFGENERIC* ...)


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

Pattern to recognize: Macro call that should be transformed by FM?

Input: (fm? 'lol-gen::some-name)

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


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

Issue: Macro call that should be transformed by FINALLY

Input: (finally)

Output: (defmacro FINALLY ...)


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

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

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

Output: (defmacro COND-<>> ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-walker-handler-lexical-environment
  nil
  :key
  nil)

What needs to change: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT

Input:
(with-walker-handler-lexical-environment
  nil
  :key
  nil)

Output: (defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)


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

Issue: Macro call that should be transformed by SET=

Input: (set= 'lol-gen::some-name)

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


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

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

Input: (define-language nil nil)

Output: (defmacro DEFINE-LANGUAGE ...)


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

Problem: Macro call that should be transformed by AWHEN

Input: (awhen nil)

Output:
(defmacro awhen (test &body body)
  "Like WHEN, except binds the result of the test to IT (via LET) for the scope
of the body."
  `(anaphoric when ,test ,@body))


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-global-var nil nil)

Issue: Macro call that should be transformed by DEFINE-GLOBAL-VAR

Input: (define-global-var nil nil)

Output: (defmacro DEFINE-GLOBAL-VAR ...)


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

What needs to change: Macro call that should be transformed by EXPORT-ALWAYS

Input: (export-always nil)

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:
Create a Common Lisp macro for the following transformation. Before code:
(list-of nil
  :key
  nil)

What needs to change: Macro call that should be transformed by LIST-OF

Input:
(list-of nil
  :key
  nil)

Output: (defmacro LIST-OF ...)


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

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

Input: (pccase nil :key nil)

Output:
(defmacro pccase (pred keyform &rest clauses)
  "Like CCASE, but uses given PRED instead of EQL to select appropriate CLAUSE.

   Example usage:

       CL-USER> (pccase '< 1
                  (0 (print \"Below zero\"))
                  (2 (print \"OK\")))
"
  (expand-predicate-case pred keyform clauses 'ccase))


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

What needs to change: Macro call that should be transformed by F-SENSITIVITY

Input:
(f-sensitivity nil
    (progn))

Output:
(defmacro f-sensitivity (synapse-id (sensitivity &optional subtypename) &body body)
  `(call-f-sensitivity ,synapse-id ,sensitivity ,subtypename (lambda () ,@body)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(as~> nil :key nil)

Issue: Macro call that should be transformed by AS~>

Input: (as~> nil :key nil)

Output:
(defmacro as~> (expr name &rest exprs)
  "Like `~>' or `~>', but instead of threading by position, threading is
done based on NAME."
  `(let* ,(loop for expr in (cons expr exprs)
                collect (list name expr))
     ,name))


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

Problem: Macro call that should be transformed by DEFVARIANT

Input: (defvariant nil)

Output: (defmacro DEFVARIANT ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(who-ps-html nil)

Problem: Macro call that should be transformed by WHO-PS-HTML

Input: (who-ps-html nil)

Output: (defmacro WHO-PS-HTML ...)


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

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

Input: (execute nil nil)

Output:
(defmacro execute (query &rest args)
  "Execute a query, ignore the results. So, in effect, like a query called with
format :none. Returns the amount of affected rows as its first returned
value. (Also returns this amount as the second returned value, but use of this
is deprecated.)"
  `(let ((rows (nth-value 1 (query ,query ,@args :none))))
     (if rows (values rows rows) 0)))


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

Issue: Macro call that should be transformed by DEFSTRUCT-READ-ONLY

Input: (defstruct-read-only 'lol-gen::some-name)

Output:
(defmacro defstruct-read-only (name-and-opts &body slots
                               &environment env)
  "Easily define a defstruct with no mutable slots.

The syntax of `defstruct-read-only' is as close as possible to that of
`defstruct'. Given an existing structure definition, you can usually
make it immutable simply by switching out `defstruct' for
`defstruct-read-only'.

There are only a few syntactic differences:

1. To prevent accidentally inheriting mutable slots, and preserve its
   own usefulness as a marker of the programmer's intent,
   `defstruct-read-only' only allows inheritance from other classes
   defined using `defstruct-read-only'.

2. The `:type' option may not be used.

3. The `:copier' option is disabled, because it would be useless.

4. Slot definitions can use slot options without having to provide an
   initform. In this case, any attempt to make an instance of the
   struct without providing a value for that slot will signal an
   error.

    (my-slot :type string)
    ≡ (my-slot (required-argument 'my-slot) :read-only t :type string)

The idea here is simply that an unbound slot in an immutable data
structure does not make sense.

A read-only struct is always externalizable; it has an implicit
definition for `make-load-form'.

On Lisps that support it, the structure is also marked as \"pure\":
that is, instances may be moved into read-only memory.

`defstruct-read-only' is designed to stay as close to the syntax of
`defstruct' as possible. The idea is to make it easy to flag data as
immutable, whether in your own code or in code you are refactoring. In
new code, however, you may sometimes prefer `defconstructor', which is
designed to facilitate working with immutable data."
  (flet ((car-safe (x) (if (consp x) (car x) nil)))
    (let ((docstring (and (stringp (first slots)) (pop slots))))
      (destructuring-bind (name . opts) (ensure-list name-and-opts)
        (when-let (copier (find :copier opts :key #'ensure-car))
          (if (null (second copier))
              (removef opts copier)
              (error "Read only struct ~a does not need a copier."
                     name)))
        (when-let (clause (find :type opts :key #'car-safe))
          (error "Read-only structs may not use the ~s option: ~a"
                 :type clause))
        (multiple-value-bind (include-clause opts)
            (include+opts opts)
          (let* ((slot-defs (mapcar #'read-only-slotdef slots))
                 (slot-names (mapcar #'first slot-defs)))
            `(progn
               (defstruct (,name (:copier nil)
                                 ;; Mark as OK to save in pure memory.
                                 #+(or sbcl cmucl) (:pure t)
                                 ,@opts
                                 ,(read-only-include-clause name include-clause env))
                 ,@(unsplice docstring)
                 ,@slot-defs)
               (defmethod read-only-struct-slot-names append ((self ,name))
                 ',slot-names)
               ',name)))))))


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

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

Input: (dletf* nil)

Output: (defmacro DLETF* ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(let-match common-lisp:nil
  (common-lisp:progn))

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

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

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:
(finishes
  'lol-gen::some-name)

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

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

Output:
(defmacro finishes (&body body)
  "Generates a pass if BODY executes to normal completion. In
other words if body does signal, return-from or throw this test
fails."
  `(unwind-protect-case () (progn ,@body)
     (:normal (add-result 'test-passed :test-expr ',body))
     (:abort (process-failure ',body "Test didn't finish"))))


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

Write a macro that addresses: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX

Input: (with-standard-io-syntax nil nil)

Output: (defmacro WITH-STANDARD-IO-SYNTAX ...)


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

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

Input:
(on nil
    nil)

Output:
(defmacro on (hook args &body body)
  "Attach a handler with ARGS and BODY to the HOOK.

ARGS can be
- A symbol if there's only one argument to the callback.
- A list of arguments.
- An empty list, if the hook handlers take no argument."
  (let ((handler-name (gensym "on-hook-handler"))
        (args (alexandria:ensure-list args)))
    `(add-hook
      ,hook (make-instance 'handler
                           :fn (lambda ,args
                                 (declare (ignorable ,@args))
                                 ,@body)
                           :name (quote ,handler-name)))))


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

Problem: Macro call that should be transformed by PROG1

Input: (prog1 nil)

Output: (defmacro PROG1 ...)


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

Write a macro that addresses: Macro call that should be transformed by UNTRACE$METHOD

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

Output: (defmacro UNTRACE$METHOD ...)


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

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

Input: (cond-> nil)

Output: (defmacro COND-> ...)


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

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

Input: (define-method-combination nil)

Output:
(defmacro define-method-combination (name &rest args)
  `(progn
     (define-method-combination% ,name ,@args)
     (c2mop:define-method-combination ,name ,@args)))


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

Problem: Macro call that should be transformed by V-DEFTYPE

Input: (v-deftype nil :key nil)

Output:
(defmacro v-deftype (name args type-form
                     &key valid-metadata-kinds)
  `(define-vari-type ,name ,args ,type-form :valid-metadata-kinds ,valid-metadata-kinds))


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

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

Input: (raw nil)

Output:
(defmacro raw (&rest forms)
  `(list ,@forms))


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

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

Input:
(defsyntax nil
  (progn))

Output:
(defmacro defsyntax (name &body options)
  `(progn
     (setf (get ',name :options) ',options)
     (defvar ,name (defreadtable ,name ,@options))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(drop-view nil)

Issue: Macro call that should be transformed by DROP-VIEW

Input: (drop-view nil)

Output:
(defmacro drop-view (view-name)
  `(make-statement :drop-view ,view-name))


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

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

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

Output:
(defmacro deftest (name &body test-forms)
  (let ((tests (gensym "TESTS"))
        (test (gensym "TEST"))
        (test-fn (gensym "TEST-FN")))
    `(progn
       (unless (nth-value 1 (gethash *package* *package-tests*))
         (setf (gethash *package* *package-tests*) '()))
       (let* ((,tests (gethash *package* *package-tests*))
              (,test (assoc ',name ,tests :test #'string=))
              (,test-fn (lambda ()
                          (subtest (princ-to-string ',name)
                            ,@test-forms))))
         (if ,test
             (rplacd ,test ,test-fn)
             (push (cons ',name ,test-fn) (gethash *package* *package-tests*)))
         ',name))))


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

Write a macro that addresses: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS

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

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


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

Problem: Macro call that should be transformed by NUNIONF

Input: (nunionf nil nil)

Output: (defmacro NUNIONF ...)


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

Issue: Macro call that should be transformed by GROWF

Input: (growf nil (progn))

Output: (defmacro GROWF ...)


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

Problem: Macro call that should be transformed by EXPORT

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

Output: (defmacro EXPORT ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(c?n-dbg
  nil)

What needs to change: Macro call that should be transformed by C?N-DBG

Input:
(c?n-dbg
  nil)

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(dynamic-progv nil
    (progn))

Issue: Macro call that should be transformed by DYNAMIC-PROGV

Input:
(dynamic-progv nil
    (progn))

Output: (defmacro DYNAMIC-PROGV ...)


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

Issue: Macro call that should be transformed by JOR

Input: (jor nil nil)

Output:
(defmacro jor (&rest args)
  "JSON-aware version of `cl:or'."
  `(or ,@(loop for arg in args
               collecting `(jwhen ,arg ,arg))))


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

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

Input:
(do+
  'lol-gen::some-name)

Output:
(defmacro do+ (&body body)
  "High-level, extensible iteration construct. Refer to the manual for syntax and semantics."
  `(do+/internal nil ,@body))


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

Problem: Macro call that should be transformed by DEFTABLE

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

Output:
(defmacro deftable (name &body definitions)
  "Define a table. name can be either a symbol or a (symbol string) list. In the
first case, the table name is derived from the symbol by S-SQL's rules, in the
second case, the name is given explicitly. The body of definitions can contain
anything that evaluates to a string, as well as S-SQL expressions. In this body,
the variables *table-name* and *table-symbol* are bound to the relevant values.
Note that the evaluation of the definition is ordered, so you will generally
want to create your table first and then define indices on it."
  (multiple-value-bind (symbol name)
      (if (consp name) (values-list name) (values name (to-sql-name name nil)))
    (flet ((check-s-sql (form)
             (if (and (consp form) (keywordp (car form))) (list 'sql form) form)))
      `(add-table-definition
        ',symbol
        (lambda ()
          (let ((*table-name* ,name) (*table-symbol* ',symbol))
            (dolist (stat (list ,@(mapcar #'check-s-sql definitions)))
              (execute stat))))))))


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 => (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:
Generate a defmacro form that transforms code like this:
(with-destructured-lambda-form nil
    (progn))

Pattern to recognize: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM

Input:
(with-destructured-lambda-form nil
    (progn))

Output: (defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)


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

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

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

Output:
(defmacro defclause (clause-template &body body)
  "Macro for defining iterate clauses (with DEFUN)."
  (define-clause 'defun clause-template body nil))


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

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

Input: (nearest nil (progn))

Output:
(defmacro nearest (self-form type)
   (let ((self (gensym)))
   `(bwhen (,self ,self-form)
       (if (typep ,self ',type) ,self (upper ,self ,type)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(ensure-transaction-with-isolation-level nil
  nil)

What needs to change: Macro call that should be transformed by ENSURE-TRANSACTION-WITH-ISOLATION-LEVEL

Input:
(ensure-transaction-with-isolation-level nil
  nil)

Output:
(defmacro ensure-transaction-with-isolation-level (isolation-level &body body)
  "Executes body within a with-transaction form if and only if no transaction is
already in progress. This adds the ability to specify an isolation level other
than the current default"
  `(call-with-ensured-transaction (lambda () ,@body) ,isolation-level))


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

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

Input: (set= nil nil)

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


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

Pattern to recognize: Macro call that should be transformed by CELL-LET

Input:
(cell-let nil
  :key
  nil)

Output:
(defmacro cell-let ((&rest bindings) &body body &environment env)
  "Define cells that are visible only to the forms in BODY.

BINDINGS is a list of cell bindings to establish, similar to
LET*. Each item in BINDINGS is a list of the form

.. code-block::

   (NAME VALUE-FORM)

where NAME is the symbol identifying the cell and VALUE-FORM is the
value form of the cell. The cell can then be referenced within the
forms in BODY by the symbol NAME.

The cells defined in BINDINGS lexcially shadow those in the
environment defined with DEFCELL or by an enclosing CELL-LET
form. Like LET* and unlike LET, each cell definition may reference the
cells defined earlier in the same CELL-LET.

The forms in BODY are evaluated in an implicit PROGN. The value
returned by the last form is returned by the CELL-LET form."

  (flet ((make-cell-binding (binding form)
           (destructuring-bind (name &optional initform)
               (ensure-list binding)

             (if (constantp initform env)
                 `(mutable-cell-let% (,name ,initform) ,form)
                 `(computed-cell-let% (,name ,initform) ,form)))))

    (->> `(progn ,@body)
         (reduce #'make-cell-binding bindings :from-end t :initial-value))))


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

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

Input: (psetq nil (progn))

Output: (defmacro PSETQ ...)


Instruction:
Generate a defmacro form that transforms code like this:
(continue-whopper nil)

Pattern to recognize: Macro call that should be transformed by CONTINUE-WHOPPER

Input: (continue-whopper nil)

Output: (defmacro CONTINUE-WHOPPER ...)


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

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

Input:
(with-attributes nil
    (progn))

Output: (defmacro WITH-ATTRIBUTES ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(ensure-gethash nil nil)

Issue: Macro call that should be transformed by ENSURE-GETHASH

Input: (ensure-gethash nil nil)

Output:
(defmacro ensure-gethash (key hash-table &optional default)
  "Like GETHASH, but if KEY is not found in the HASH-TABLE saves the DEFAULT
under key before returning it. Secondary return value is true if key was
already in the table."
  (once-only (key hash-table)
    (with-unique-names (value presentp)
      `(multiple-value-bind (,value ,presentp) (gethash ,key ,hash-table)
         (if ,presentp
             (values ,value ,presentp)
             (values (setf (gethash ,key ,hash-table) ,default) nil))))))


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

Problem: Macro call that should be transformed by LAMBDA-EMATCH*

Input:
(lambda-ematch*
  common-lisp:nil
  common-lisp:nil)

Output:
(defmacro lambda-ematch* (&body body)
  "Equivalent to (lambda (args...) (ematch* (args...) BODY...))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    (let ((gensyms (make-gensyms (caar clauses))))
      `(lambda ,gensyms
         ,@preamble
         (ematch* ,gensyms
           ,@clauses)))))


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

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

Input:
(select nil
  :key
  nil)

Output:
(defmacro select (keyform &body clauses)
  "Like `case', but with evaluated keys.

Note that, like `case', `select' interprets a list as the first
element of a clause as a list of keys. To use a form as a key, you
must add an extra set of parentheses.

     (select 2
       ((+ 2 2) t))
     => T

     (select 4
       (((+ 2 2)) t))
     => T

From Zetalisp."
  `(selector ,keyform eql
     ,@clauses))


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

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

Input: (restart-bind nil)

Output: (defmacro RESTART-BIND ...)


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

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

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

Output: (defmacro -<>> ...)


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

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

Input:
(deftest nil
  nil)

Output:
(defmacro deftest (name &body test-forms)
  (let ((tests (gensym "TESTS"))
        (test (gensym "TEST"))
        (test-fn (gensym "TEST-FN")))
    `(progn
       (unless (nth-value 1 (gethash *package* *package-tests*))
         (setf (gethash *package* *package-tests*) '()))
       (let* ((,tests (gethash *package* *package-tests*))
              (,test (assoc ',name ,tests :test #'string=))
              (,test-fn (lambda ()
                          (subtest (princ-to-string ',name)
                            ,@test-forms))))
         (if ,test
             (rplacd ,test ,test-fn)
             (push (cons ',name ,test-fn) (gethash *package* *package-tests*)))
         ',name))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-special-initargs* nil
  (progn))

Issue: Macro call that should be transformed by WITH-SPECIAL-INITARGS*

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

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


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(c?+n)

Write a macro that addresses: Macro call that should be transformed by C?+N

Input: (c?+n)

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


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

Issue: Macro call that should be transformed by WHILE

Input:
(while nil
  (progn))

Output: (defmacro WHILE ...)


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

What needs to change: Macro call that should be transformed by SELECT-DAO

Input: (select-dao nil (progn))

Output:
(defmacro select-dao (type &optional (test t) &rest ordering)
  "Select DAO objects for the rows in the associated table for which the given
test (either an S-SQL expression or a string) holds. When sorting arguments
are given, which can also be S-SQL forms or strings, these are used to sort
the result.

(Note that, if you want to sort, you have to pass the test argument.)

    (select-dao 'user (:> 'score 10000) 'name)"

  `(query-dao% ,type (sql ,(generate-dao-query type test ordering))
               (dao-row-reader (find-class ,type))))


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

Problem: Macro call that should be transformed by SELECT

Input:
(select nil
  nil)

Output:
(defmacro select (fields &body clauses)
  `(make-statement :select
                   ,(match fields
                      ((or (list* (type keyword) _)
                           (list* (list* (type keyword) _) _))
                       `(make-clause :fields
                                     ,@(mapcar #'expand-op fields)))
                      ((type keyword) `(fields ,fields))
                      ((or (type symbol)
                           (list* (type symbol) _))
                       `(convert-if-fields-clause ,fields))
                      (otherwise fields))
                   ,@clauses))


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

Issue: Macro call that should be transformed by DLET*

Input:
(dlet* nil
  :key
  nil)

Output: (defmacro DLET* ...)


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

Pattern to recognize: Macro call that should be transformed by LIST-OF

Input:
(list-of nil
  (progn))

Output: (defmacro LIST-OF ...)


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

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

Input: (is-false nil)

Output:
(defmacro is-false (condition &rest reason-args)
  "Generates a pass if CONDITION returns false, generates a
  failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does
  not inspect CONDITION to determine what reason to give it case
  of test failure"
  (with-gensyms (value)
    `(let ((,value ,condition))
       (if ,value
           (process-failure ',condition
                            ,@(or reason-args
                                  `("~S returned the value ~S, which is true" ',condition ,value)))
           (add-result 'test-passed :test-expr ',condition)))))


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

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

Input:
(block-compile nil
  (progn))

Output:
(defmacro block-compile ((&key entry-points
                               (block-compile t))
                         &body body)
  "Shorthand for block compilation with `local*'.

Only the functions in ENTRY-POINTS will have global definitions. All
other functions in BODY will be compiled as purely local functions,
and all of their calls to one another will be compiled as local calls.
This includes calls to the entry points, and even self-calls from
within the entry points.

Note that `declaim' forms occuring inside of BODY will be translated
into local `declare' forms.

If you pass `:block-compile nil', this macro is equivalent to progn.
This may be useful during development."
  (if (not block-compile) `(progn ,@body)
      `(local*
         ,@body
         (progn
           ,@(loop for entry-point in entry-points
                   collect `(defalias ,entry-point #',entry-point))))))


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

What needs to change: Macro call that should be transformed by NUMBER-LITERAL

Input: (number-literal 'lol-gen::some-name)

Output: (defmacro NUMBER-LITERAL ...)


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

Problem: Macro call that should be transformed by DESTRUCTURING-BIND

Input: (destructuring-bind () :key nil)

Output: (defmacro DESTRUCTURING-BIND ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(optimize common-lisp:nil
  :key
  common-lisp:nil)

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

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

Output: (defmacro OPTIMIZE ...)


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

Issue: Macro call that should be transformed by ->

Input:
(-> nil
  nil)

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


Instruction:
Write a Common Lisp macro to handle this code pattern:
;; Building a closure with mutable behavior requires manual forwarding
(let ((counter 0)
      (impl (lambda (n) (incf counter n))))
  (lambda (&rest args)
    (apply impl args)))

;; To change behavior: build an entirely new closure

Problem: Need mutable closure behavior changeable at runtime, with implicit 'this' pointing to current implementation

Input:
;; Building a closure with mutable behavior requires manual forwarding
(let ((counter 0)
      (impl (lambda (n) (incf counter n))))
  (lambda (&rest args)
    (apply impl args)))

;; To change behavior: build an entirely new closure

Output:
(defmacro alet (letargs &rest body)
  `(let ((this) ,@letargs)
     (setq this ,@(last body))
     ,@(butlast body)
     (lambda (&rest params)
       (apply this params))))


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

Issue: Macro call that should be transformed by MODF

Input: (modf nil nil)

Output:
(defmacro modf (place value &rest more &environment env)
  "Make a new object \(which may use some of the old object) such that PLACE
evaluates to VALUE.

MORE should have the form...

MORE : NIL
     | (TEMPORARY-BINDING ANOTHER-MODF-PLACE ANOTHER-VALUE . MORE)

Use it to specify a temporary binding for the new object created which will be
used in the subsequence MODF-PLACE NEW-VALUE pairs until the end of the MODF
form."
  (if more
      (destructuring-bind (next-symbol next-place next-value &rest next-more) more
        `(let ((,next-symbol ,(modf-expand value place nil env)))
           (modf ,next-place ,next-value ,@next-more)))
      (modf-expand value place nil env)))


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 <$ (item parser)
  "Run some parser, but substitute its inner value with some `item' if parsing was
  successful."
  (let ((offset (gensym "<$-OFFSET"))
        (res    (gensym "<$-RES"))
        (next   (gensym "<$-NEXT")))
    `(lambda (,offset)
       (multiple-value-bind (,res ,next) (funcall ,parser ,offset)
         (if (failure? ,res)
             (fail ,next)
             (values ,item ,next))))))


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

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

Input: (minimizing nil)

Output: (defmacro MINIMIZING ...)


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

Problem: Macro call that should be transformed by PPRINT-COALTON-CODEGEN

Input:
(pprint-coalton-codegen
  'lol-gen::some-name)

Output: (defmacro PPRINT-COALTON-CODEGEN ...)


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

Problem: Macro call that should be transformed by SLET

Input:
(slet nil
  nil)

Output:
(defmacro slet (form &body body)
  "Binds the FORM to IT (via SYMBOL-MACROLET) in the scope of the BODY. IT can
be set with SETF."
  `(symbolic ignore-first ,form (progn ,@body)))


Instruction:
Define a macro that eliminates this repetitive pattern:
;; Depth-first search with manual backtracking
(defun search (node)
  (if (goal-p node)
      node
      (let ((children (expand node)))
        (when children
          (let ((result (search (car children))))
            (if result
                result
                (when (cdr children)
                  (search (cadr children)))))))))
;; Manual backtracking is error-prone and obscures the search logic

Issue: Search/backtracking algorithms require manual state management — want implicit backtracking via nondeterministic choice

Input:
;; Depth-first search with manual backtracking
(defun search (node)
  (if (goal-p node)
      node
      (let ((children (expand node)))
        (when children
          (let ((result (search (car children))))
            (if result
                result
                (when (cdr children)
                  (search (cadr children)))))))))
;; Manual backtracking is error-prone and obscures the search logic

Output:
(defparameter *paths* nil)
(defconstant failsym '@)

(defmacro choose (&rest choices)
  (if choices
      `(progn
         ,@(mapcar #'(lambda (c)
                       `(push #'(lambda () ,c) *paths*))
                   (reverse (cdr choices)))
         ,(car choices))
      '(fail)))

(defmacro choose-bind (var choices &body body)
  `(cb #'(lambda (,var) ,@body) ,choices))

(defun cb (fn choices)
  (if choices
     (progn
       (if (cdr choices)
           (push #'(lambda () (cb fn (cdr choices)))
                 *paths*))
       (funcall fn (car choices)))
     (fail)))

(defun fail ()
  (if *paths*
      (funcall (pop *paths*))
      failsym))


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

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

Input:
(aetypecase nil
  :key
  nil)

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


Instruction:
Write a Common Lisp macro to handle this code pattern:
(define-global-parameter* nil :key nil)

Problem: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER*

Input: (define-global-parameter* nil :key nil)

Output: (defmacro DEFINE-GLOBAL-PARAMETER* ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(v-defstruct nil
    :key
  nil)

Issue: Macro call that should be transformed by V-DEFSTRUCT

Input:
(v-defstruct nil
    :key
  nil)

Output:
(defmacro v-defstruct (name context &body slots)
  `(define-vari-struct ,name ,context ,@slots))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(ignore-errors)

Problem: Macro call that should be transformed by IGNORE-ERRORS

Input: (ignore-errors)

Output: (defmacro IGNORE-ERRORS ...)


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

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

Input: (defmethod nil (progn))

Output:
(defmacro defmethod (name &rest args)
  (handler-case
      (multiple-value-bind (qualifiers specializers lambda-list body)
          (parse-method args)

        (declare (ignore qualifiers))

        (with-gensyms (method)
          (let ((fn-name (gentemp (symbol-name (block-name name)) *method-function-package*)))
            `(progn
               ,(make-method-function name fn-name lambda-list body)

               (let ((,method
                      (walk-environment
                        (c2mop:defmethod ,name ,@args))))

                 (when (combination-options ',name)
                   ,(make-add-method-info name method fn-name body)
                   ,(make-static-dispatch name lambda-list specializers))

                 ,method)))))

    (error (e)
      (simple-style-warning "Error parsing DEFMETHOD form:~%~2T~a" e)
      `(walk-environment
         (c2mop:defmethod ,name ,@args)))))


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

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

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

Output: (defmacro WITH* ...)


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

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

Input:
(c_?
  nil
  nil)

Output:
(defmacro c_? (&body body)
  "Lazy until asked, then eagerly propagating"
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :lazy :until-asked
    :rule (c-lambda ,@body)))


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

Issue: Macro call that should be transformed by WTRC

Input:
(wtrc nil
  nil)

Output:
(defmacro wtrc ((&optional (min 1) (max 50) &rest banner) &body body )
  `(let ((*trcdepth* (if *trcdepth*
                         (1+ *trcdepth*)
                       0)))
     ,(when banner `(when (>= *trcdepth* ,min)
                      (if (< *trcdepth* ,max)
                          (trc ,@banner)
                        (progn
                          (break "excess trace notttt!!! ~d" *trcdepth*) ;; ,@banner)
                          nil))))
     (when (< *trcdepth* ,max)
       ,@body)))


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

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

Input: (returning nil nil)

Output: (defmacro RETURNING ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(c-input-dbg)

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

Input: (c-input-dbg)

Output:
(defmacro c-input-dbg (&optional (value nil valued-p))
  `(make-cell
    :inputp t
    :debug t
    :value-state ,(if valued-p :valid :unbound)
    :value ,value))


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

Problem: Macro call that should be transformed by SOME-<>>

Input:
(some-<>>
  nil
  nil)

Output: (defmacro SOME-<>> ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(c?n-dbg)

Write a macro that addresses: Macro call that should be transformed by C?N-DBG

Input: (c?n-dbg)

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


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

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

Input: (with-forced-status 'lol-gen::some-name)

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


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

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

Input:
(with-access nil
    nil)

Output:
(defmacro with-access ((&rest keys) val-form &body body)
  "Similar to with-accessors except using the access functions"
  (let* ((gval (gensym "val"))
     (forms
      (iter (for k in keys)
        (for (k-to k-from) = (if (listp k) k (list k k)))
        (collect `(,k-to (access ,gval ',k-from))))))
    `(let ((,gval ,val-form))
       (declare (ignorable ,gval))
       (symbol-macrolet (,@forms)
     ,@body
     ))))


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

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

Input:
(with-yield
  nil
  nil)

Output: (defmacro WITH-YIELD ...)


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

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

Input: (in-package nil)

Output: (defmacro IN-PACKAGE ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(is-expand nil (progn))

Issue: Macro call that should be transformed by IS-EXPAND

Input: (is-expand nil (progn))

Output:
(defmacro is-expand (got expected &optional desc)
  (with-gensyms (duration expanded)
    (once-only (desc)
      `(with-duration ((,duration ,expanded) (macroexpand-1 ',got))
         (let (*gensym-alist*)
           (test ,expanded ',expected ,desc
                 :duration ,duration
                 :got-form ',got
                 :report-expected-label "be expanded to"
                 :test-fn #'gensym-tree-equal))))))


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

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

Input:
(defgenerator nil
    nil)

Output:
(defmacro defgenerator (name arguments &body body)
  (multiple-value-bind (remaining-forms declarations doc-string)
      (alexandria:parse-body body :documentation t)
    `(defun ,name ,arguments
       ,doc-string
       ,@declarations
       (with-yield
	 ,@remaining-forms))))


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

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

Input: (set= nil (progn))

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


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

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

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

Output:
(defmacro with-boolean ((&rest branches) &body body
                        &environment env)
  "Establishes a lexical environment in which it is possible to use
macroexpand-time branching. Within the lexical scope of
`with-boolean', it is possible to use `boolean-if', `boolean-when',
and `boolean-unless' to conditionalize whether some forms are included
at compilation time. (You may also use `:if', `:when', or `:unless'
for brevity.)
\
The first argument must be a list of symbols which name variables. This macro
will expand into a series of conditionals"
  (cond (*boolean-bypass*
         `(progn ,@body))
        (t (let ((all-branches (macroexpand-1 '%all-branches% env)))
             `(macrolet ((:if (cond then else)
                              (list 'boolean-if cond then else))
                         (:when (cond &body then)
                           (list* 'boolean-when cond then))
                         (:unless (cond &body then)
                           (list* 'boolean-unless cond then)))
                (locally
                    (declare #+sbcl (sb-ext:disable-package-locks
                                     %in-branching% %all-branches%)
                             #+sbcl (sb-ext:muffle-conditions
                                     sb-ext:code-deletion-note))
                  (symbol-macrolet ((%in-branching% t)
                                    (%all-branches% (,@branches ,@all-branches))
                                    (%true-branches% ()))
                    (locally (declare #+sbcl (sb-ext:enable-package-locks
                                              %in-branching% %all-branches%))
                      (%with-boolean ,branches ,@body)))))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(maybe-once-only nil
  (progn))

What needs to change: Macro call that should be transformed by MAYBE-ONCE-ONLY

Input:
(maybe-once-only nil
  (progn))

Output: (defmacro MAYBE-ONCE-ONLY ...)


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

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

Input: (finally nil)

Output: (defmacro FINALLY ...)


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

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

Input:
(with-gensyms nil
  :key
  nil)

Output:
(defmacro with-gensyms (names &body forms)
  "Binds a set of variables to gensyms and evaluates the implicit progn FORMS.

Each element within NAMES is either a symbol SYMBOL or a pair (SYMBOL
STRING-DESIGNATOR). Bare symbols are equivalent to the pair (SYMBOL SYMBOL).

Each pair (SYMBOL STRING-DESIGNATOR) specifies that the variable named by SYMBOL
should be bound to a symbol constructed using GENSYM with the string designated
by STRING-DESIGNATOR being its first argument."
  `(let ,(mapcar (lambda (name)
                   (multiple-value-bind (symbol string)
                       (etypecase name
                         (symbol
                          (values name (symbol-name name)))
                         ((cons symbol (cons string-designator null))
                          (values (first name) (string (second name)))))
                     `(,symbol (gensym ,string))))
                 names)
     ,@forms))


Instruction:
Define a macro that eliminates this repetitive pattern:
(incf-pointer nil)

Issue: Macro call that should be transformed by INCF-POINTER

Input: (incf-pointer nil)

Output: (defmacro INCF-POINTER ...)


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

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

Input:
(with-savepoint nil
  :key
  nil)

Output:
(defmacro with-savepoint (conn &body body)
  (let ((ok (gensym "SAVEPOINT-OK"))
        (state-var (gensym "STATE-VAR"))
        (ident-var (gensym "SAVEPOINT-IDENTIFIER-VAR")))
    `(let* ((,state-var (make-instance 'savepoint-state
                                       :conn ,conn))
            (,ident-var (get-identifier ,state-var))
            (*transaction-state*
              (cons ,state-var
                    *transaction-state*))
            ,ok)

       (savepoint ,conn ,ident-var)
       (unwind-protect
            (multiple-value-prog1
                (progn ,@body)
              (setf ,ok t))
         (when (eql (get-state ,state-var)
                    :in-progress)
           (if ,ok
               (release-savepoint ,conn ,ident-var)
               (rollback-savepoint ,conn ,ident-var)))))))


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

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

Input:
(defaction nil
    nil)

Output: (defmacro DEFACTION ...)


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

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

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

Output:
(defmacro ensure2 (place &body newval &environment env)
  "Like `ensure', but specifically for accessors that return a second
value like `gethash'."
  (multiple-value-bind (vars vals stores setter getter)
      (get-setf-expansion place env)
    (with-gensyms (old presentp)
      `(let* ,(mapcar #'list vars vals)
         (multiple-value-bind (,old ,presentp)
             ,getter
           (if ,presentp
               ,old
               (multiple-value-bind ,stores
                   (progn ,@newval)
                 ,setter)))))))


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

Problem: Macro call that should be transformed by MODF-EVAL

Input: (modf-eval nil)

Output:
(defmacro modf-eval (&rest args)
  `(progn ,@args))


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

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

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

Output: (defmacro POP ...)


Instruction:
Generate a defmacro form that transforms code like this:
(ensure-transaction)

Pattern to recognize: Macro call that should be transformed by ENSURE-TRANSACTION

Input: (ensure-transaction)

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:
Define a macro that eliminates this repetitive pattern:
(modf-eval nil :key nil)

Issue: Macro call that should be transformed by MODF-EVAL

Input: (modf-eval nil :key nil)

Output:
(defmacro modf-eval (&rest args)
  `(progn ,@args))


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

Problem: Macro call that should be transformed by MAKE-METHOD

Input: (make-method nil)

Output:
(defmacro make-method (form)
  `(cl:make-method ,form))


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

Problem: Macro call that should be transformed by CLL-OUTER

Input:
(cll-outer nil
  :key
  nil)

Output:
(defmacro cll-outer (val &body body)
 `(let ((outer-val ,val))
    ,@body))


Instruction:
Define a macro that eliminates this repetitive pattern:
(count-failures)

Issue: Macro call that should be transformed by COUNT-FAILURES

Input: (count-failures)

Output: (defmacro COUNT-FAILURES ...)


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

Pattern to recognize: Macro call that should be transformed by SOME->>

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

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


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(try-as common-lisp:nil)

What needs to change: Macro call that should be transformed by TRY-AS

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

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

    (try-as <type> <expr>)

is equivalent to

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

and

    (try-as <type>)

is equivalent to

    (fn (expr) (the (Optional <type>) (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")))
           (Optional (cl:ignore-errors (cl:find-symbol "OPTIONAL" "COALTON/CLASSES"))))
    (cl:assert try-into () "`try-as` macro does not have access to `try-into` yet.")
    (cl:assert Optional () "`try-as` macro does not have access to `Optional` yet.")
    (cl:if expr-supplied-p
           `(the (,Optional ,type) (,try-into ,expr))
           (alexandria:with-gensyms (lexpr)
             `(fn (,lexpr)
                (the (,Optional ,type) (,try-into ,lexpr)))))))


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

Issue: Macro call that should be transformed by DEFMETHOD

Input: (defmethod nil (progn))

Output: (defmacro DEFMETHOD ...)


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

Issue: Macro call that should be transformed by LAMBDA*

Input:
(lambda* nil
  :key
  nil)

Output: (defmacro LAMBDA* ...)


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

Issue: Macro call that should be transformed by DEFINE-METHOD-COMBINATION

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

Output:
(defmacro define-method-combination (name &rest args)
  `(progn
     (define-method-combination% ,name ,@args)
     (c2mop:define-method-combination ,name ,@args)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(ignorable common-lisp:nil
  (common-lisp:progn))

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

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

Output: (defmacro IGNORABLE ...)


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

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

Input:
(with-proxynodes nil
  nil)

Output:
(defmacro with-proxynodes (proxy-nodes &body body)
  "define proxy nodes for local usage"
  (if (not (listp proxy-nodes))
      (setf proxy-nodes (list proxy-nodes)))
  (if proxy-nodes
      (let ((tmp (gensym (format nil "~:@(proxy-~a-~)" (first proxy-nodes)))))
	;(format t "Symbol:: ~s" tmp)
	(setf (gethash (first proxy-nodes) *proxy-node*) tmp)
	;;for debug/swank, else comment out
	;;(eval `(defnode ,tmp (proxy) ()))
	;;
	`(let ((,(first proxy-nodes) ',tmp))

	     ;(defnode ,tmp (proxy) ())
	     (defproxy ,tmp)

	     (with-proxynodes ,(rest proxy-nodes) ,@body)))
      `(progn ,@body)))


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

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

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

Output: (defmacro MAXIMIZING ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(custom-decoder nil :key nil)

Issue: Macro call that should be transformed by CUSTOM-DECODER

Input: (custom-decoder nil :key nil)

Output:
(defmacro custom-decoder (&rest customizations)
  "Return a function which is like DECODE-JSON called in a dynamic
environment with the given CUSTOMIZATIONS."
  `(lambda (&optional (stream *json-input*))
     (bind-custom-vars ,customizations
       (decode-json stream))))


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

Problem: Macro call that should be transformed by WITH-READ-ONLY-VARS

Input:
(with-read-only-vars nil
  nil)

Output:
(defmacro with-read-only-vars ((&rest vars) &body body &environment env)
  "Make VARS read-only within BODY.

That is, within BODY, each var in VARS is bound as a symbol macro,
which expands into a macro whose setf expander, in turn, is defined to
signal a warning at compile time, and an error at run time.

Depending on your Lisp implementation this may or may not do anything,
and may or may not have an effect when used on special variables."
  (declare (ignorable env))
  (case uiop:*implementation-type*
    ((:ccl :sbcl :cmu :acl)
     ;; The use of temps here, while it is ugly and annoying when
     ;; debugging, is necessary to prevent symbol-macrolet from going
     ;; into an infinite loop.
     (let* ((vars (loop for var in vars
                        unless (variable-special? var env)
                          collect var))
            (temps
              (loop for var in vars
                    collect (gensym (string var)))))
       `(let ,(mapcar #'list temps vars)
          (declare (ignorable ,@temps))
          (symbol-macrolet ,(loop for var in vars
                                  for temp in temps
                                  collect `(,var (read-only-var ,temp ,var)))
            ,@body))))
    (t
     `(locally ,@body))))


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

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

Input: (defgeneric* nil nil)

Output: (defmacro DEFGENERIC* ...)


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

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

Input:
(possibly?
  nil
  :key
  nil)

Output: (defmacro POSSIBLY? ...)


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

Problem: Macro call that should be transformed by DEFUN-MATCH*

Input:
(defun-match* common-lisp:nil
    common-lisp:nil)

Output:
(defmacro defun-match* (name args &body body)
  "Equivalent to (defun (arg) [decl-and-docstring] (match arg (PATTERN BODY...)))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    `(defun ,name ,args
       ,@preamble
       (match* ,args
         ,@clauses))))


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

Problem: Macro call that should be transformed by DEFUN-CMATCH

Input:
(defun-cmatch common-lisp:nil
    (common-lisp:progn))

Output:
(defmacro defun-cmatch (name (arg) &body body)
  "Equivalent to (defun (arg) [decl-and-docstring] (cmatch arg (PATTERN BODY...)))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    `(defun ,name (,arg)
       ,@preamble
       (cmatch ,arg
         ,@clauses))))


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

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

Input: (all nil (progn))

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


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

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

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

Output: (defmacro COLLECT-MIN ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(eko-if nil)

Issue: Macro call that should be transformed by EKO-IF

Input: (eko-if 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:
Define a macro that eliminates this repetitive pattern:
(cll-outer nil
  nil)

Issue: Macro call that should be transformed by CLL-OUTER

Input:
(cll-outer nil
  nil)

Output:
(defmacro cll-outer (val &body body)
 `(let ((outer-val ,val))
    ,@body))


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

Issue: Macro call that should be transformed by MAKE

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

Output: (defmacro MAKE ...)


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

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

Input:
(when-let nil
  :key
  nil)

Output:
(defmacro when-let (bindings &body forms)
    "Creates new variable bindings, and conditionally executes FORMS.

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 all variables were bound to true values, then FORMS are executed as an
implicit PROGN."
  (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                           (list bindings)
                           bindings))
         (variables (mapcar #'car binding-list)))
    `(let ,binding-list
       (when (and ,@variables)
         ,@forms))))


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

Issue: Macro call that should be transformed by LETREC

Input:
(letrec nil
  nil)

Output:
(defmacro letrec ((&rest bindings) &body body)
  "Recursive LET.
The idea is that functions created in BINDINGS can close over one
another, and themselves.

Note that `letrec' only binds variables: it can define recursive
functions, but can't bind them as functions. (But see `fbindrec'.)"
  `(letrec-with psetq ,bindings
     ,@body))


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

Problem: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL

Input: (with-custom-decoder-level nil)

Output:
(defmacro with-custom-decoder-level ((&rest customizations) &body body)
  "Execute BODY in a dynamic environment such that, when nested
structures are decoded, the outermost level is decoded with the given
custom handlers (CUSTOMIZATIONS) whereas inner levels are decoded in
the usual way."
  `(let ((current-decoder
          (current-decoder
           ,@(loop for (key value) on customizations by #'cddr
                if (eq key :internal-decoder)
                  do (error "~S ~S customization is meaningless in ~
                             the context of WITH-CUSTOM-DECODER-LEVEL."
                            key value)
                else collect key))))
     (bind-custom-vars (:internal-decoder current-decoder ,@customizations)
       ,@body)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-vector-dispatch nil
    (progn))

Issue: Macro call that should be transformed by WITH-VECTOR-DISPATCH

Input:
(with-vector-dispatch nil
    (progn))

Output:
(defmacro with-vector-dispatch ((&rest types) var &body body)
  "Like `with-subtype-dispatch' with an overall type of `vector'."
  ;; Always specialize for simple vectors.
  `(with-subtype-dispatch vector (simple-vector ,@types) ,var
     ,@body))


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

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

Input:
(cond->>
  nil
  nil)

Output: (defmacro COND->> ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(and-it nil)

Issue: Macro call that should be transformed by AND-IT

Input: (and-it nil)

Output:
(defmacro and-it (&rest args)
  "Like AND. IT is bound to the value of the previous AND form."
  (cond ((null args) t)
        ((null (cdr args)) (car args))
        (t `(when-it ,(car args) (and-it ,@(cdr args))))))


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

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

Input:
(define-generic nil
    (progn))

Output:
(defmacro define-generic (name (&rest arglist) &body body)
  "Convenience macro to define generics as if they were methods.
ARGLIST can be a method arglist, in which case it's parsed into
generic function arglist by removing method-specific args.

BODY can be a list of `defgeneric' options (processed as-is, even
:method ones) intermixed with other Lisp forms:
- If there's a docstring as the first form, it's processed into
  :documentation option of `defgeneric'.
- If there are non-option forms, they are put together into a separate
  :method option under ARGLIST.
- If there's a `declare' form:
  - If it's generic-friendly (optimize for speed or space), then it's
    put into both generic body and :method body (if any).
  - Otherwise it's only put into :method (creating it if necessary).
- If there's an `:export-generic-name-p' boolean option, export (T) or
  don't export (NIL) the generic symbol.

Example:

\(define-generic add ((a integer) (b integer) &key coerce-to-fixnum &allow-other-keys)
  \"Adds A and B, coercing them to fixnum if the sum is too big.\"
  (if coerce-to-fixnum
      (coerce (+ a b) 'fixnum)
      (+ a b))
  (:method ((a string) (b integer))
   (error \"Cannot use `add' on strings!\")))
=>
\(defgeneric add (a b &key &allow-other-keys)
  (:method ((a integer) (b integer) &key coerce-to-fixnum &allow-other-keys)
   (if coerce-to-fixnum
      (coerce (+ a b) 'fixnum)
      (+ a b)))
  (:method ((a string) (b integer))
   (error \"Cannot use `add' on strings!\"))
  (:documentation \"Adds A and B, coercing them to fixnum if the sum is too big.\"))"
  (multiple-value-bind (body declarations documentation)
      (uiop:parse-body body :documentation t)
    (when (and (= 1 (length body))
               (stringp (first body)))
      (style-warn "Body of DEFINE-GENERIC contains a single string:
~s.
It's interpreted as a method body by default.

If you meant this string to be a generic docstring, and not a method
body, add an explicit NIL or some other body form:
(define-generic name (arg1 arg2)
  \"Docstring\"
  'body-form)

If you meant it as a body form, do nothing, or provide explicit
documentation or any other option:
(define-generic name (arg1 arg2)
  \"Docstring\"
  (:documentation \"Real docstring\"))" (first body)))
    (let* ((generic-declarations (remove-if (lambda (d)
                                              (or (> (length d) 2)
                                                  (not (eq 'optimize (first (second d))))
                                                  (notevery (lambda (o)
                                                              (let ((feature (first (uiop:ensure-list o))))
                                                                (or (eq feature 'speed)
                                                                    (eq feature 'space))))
                                                            (rest (second d)))))
                                            declarations))
           (options (remove-if-not (lambda (form)
                                     (keywordp (first (uiop:ensure-list form))))
                                   body))
           (method-body (remove-if (lambda (f) (member f options :test #'equal)) body))
           (export-generic-name-p (find :export-generic-name-p options :key #'first))
           (options (remove export-generic-name-p options :test #'equal))
           (export-p (if export-generic-name-p
                         (second export-generic-name-p)
                         *export-generic-name-p*))
           (generalized-arglist (generalize-arglist arglist)))
      (when (and (not (equal generalized-arglist arglist))
                 (every #'null (list method-body options)))
        (style-warn "Specialized arglist used without method body in define-generic: ~a" arglist))
      `(prog1
           (defgeneric ,name ,generalized-arglist
             ,@generic-declarations
             ,@(when (or method-body
                         (not (equal generic-declarations
                                     declarations)))
                 `((:method ,arglist
                     ,@declarations
                     ,@method-body)))
             ,@options
             ,@(when documentation
                 `((:documentation ,documentation))))
         ;; FIXME: Maybe only export if package of generic function name
         ;; matches *PACKAGE*?
         ,@(when export-p
             `((eval-when (:compile-toplevel :load-toplevel :execute)
                 (export ',name ,(package-name *package*)))))
         ,@(let ((documentation (or documentation
                                    (second (first (member :documentation options :key #'first))))))
             (when documentation
               `((setf (documentation ',name 'function) ,documentation)
                 (setf (documentation (fdefinition ',name) 'function) ,documentation))))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(inext-noexit nil)

Issue: Macro call that should be transformed by INEXT-NOEXIT

Input: (inext-noexit nil)

Output: (defmacro INEXT-NOEXIT ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(def-kid-slots nil :key nil)

Issue: Macro call that should be transformed by DEF-KID-SLOTS

Input: (def-kid-slots nil :key nil)

Output:
(defmacro def-kid-slots (&rest slot-defs)
  `(lambda (self)
     (declare (ignorable self))
     (list ,@slot-defs)))


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

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

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

Output: (defmacro SOME-<>> ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-capped-stack nil
  (progn))

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

Input:
(with-capped-stack nil
  (progn))

Output:
(defmacro with-capped-stack (() &body body)
  `(stack-capper (lambda () ,@body)))


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

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

Input:
(with-condition-restarts nil
    nil)

Output: (defmacro WITH-CONDITION-RESTARTS ...)


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

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

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

Output: (defmacro OPTIMIZE ...)


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

Issue: Macro call that should be transformed by NREVERSEF

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

Output: (defmacro NREVERSEF ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(pprint-coalton-codegen-ast
  common-lisp:nil)

What needs to change: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST

Input:
(pprint-coalton-codegen-ast
  common-lisp:nil)

Output: (defmacro PPRINT-COALTON-CODEGEN-AST ...)


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

Pattern to recognize: Macro call that should be transformed by DEFMACRO/PS

Input:
(defmacro/ps nil
    nil)

Output: (defmacro DEFMACRO/PS ...)


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

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

Input: (annotation nil (progn))

Output: (defmacro ANNOTATION ...)


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

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

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

Output: (defmacro INCF ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(multiple-value-match common-lisp:nil
  (common-lisp:progn))

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

Input:
(multiple-value-match common-lisp:nil
  (common-lisp:progn))

Output:
(defmacro multiple-value-match (values-form &body clauses)
  #.+multiple-value-match-doc+
  (call-with-mvb-temp-vars
   clauses
   (lambda (clauses temps)
     `(multiple-value-bind  ,temps ,values-form
        (match* ,temps
          ,@clauses)))))


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

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

Input:
(setypecase nil
  (progn))

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


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

Write a macro that addresses: Macro call that should be transformed by INEXT-NOEXIT

Input: (inext-noexit nil (progn))

Output: (defmacro INEXT-NOEXIT ...)


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

What needs to change: Macro call that should be transformed by MIN-OF

Input:
(min-of nil
  (progn))

Output: (defmacro MIN-OF ...)


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

Problem: Macro call that should be transformed by DEFWALKER-HANDLER

Input: (defwalker-handler nil)

Output: (defmacro DEFWALKER-HANDLER ...)


Instruction:
Generate a defmacro form that transforms code like this:
(with-walker-handler-lexical-environment
  nil
  (progn))

Pattern to recognize: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT

Input:
(with-walker-handler-lexical-environment
  nil
  (progn))

Output: (defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)


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

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

Input: (-<>> nil nil)

Output: (defmacro -<>> ...)