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

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

Input:
(c?once
  nil
  :key
  nil)

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


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

Issue: Macro call that should be transformed by EXPORT

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

Output: (defmacro EXPORT ...)


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

Problem: Macro call that should be transformed by DEFJSMACRO

Input: (defjsmacro nil :key nil)

Output: (defmacro DEFJSMACRO ...)


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

Pattern to recognize: Macro call that should be transformed by CHECK-TYPE

Input: (check-type nil (progn))

Output: (defmacro CHECK-TYPE ...)


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

Issue: Macro call that should be transformed by DEFMETHOD

Input: (defmethod nil nil)

Output: (defmacro DEFMETHOD ...)


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

Issue: Macro call that should be transformed by WITH-GUESSING-ENCODER

Input:
(with-guessing-encoder
  'lol-gen::some-name)

Output:
(defmacro with-guessing-encoder  (&body body)
  `(with-local-encoder (use-guessing-encoder)
     ,@body))


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

Write a macro that addresses: Macro call that should be transformed by WITH-READ-ONLY-VARS

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

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

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

Input: (prepare nil)

Output:
(defmacro prepare (query &optional (format :rows))
  "Wraps a query into a function that can be used as the interface to a prepared
statement. The given query (either a string or an S-SQL form) may contain
placeholders, which look like $1, $2, etc. The resulting function takes one
argument for every placeholder in the query, executes the prepared query, and
returns the result in the format specified. (Allowed formats are the same as for
query.)

For queries that have to be run very often, especially when they are complex,
it may help performance since the server only has to plan them once. See the
http://www.postgresql.org/docs/current/static/sql-prepare.html
in the PostgreSQL manual for details.

In some cases, the server will complain about not being able to deduce the type
of the arguments in a statement. In that case you should add type
declarations (either with the PostgreSQL's CAST SQL-conforming syntax or
historical :: syntax, or with S-SQL's :type construct) to help it out.

Note that it will attempt to automatically reconnect if database-connection-error,
or admin-shutdown. It will reset prepared statements triggering an
invalid-sql-statement-name error. It will overwrite old prepared statements
triggering a duplicate-prepared-statement error."
  `(let ((overwrite ,*allow-overwriting-prepared-statements*))
     ,(generate-prepared '(lambda) (next-statement-id) query format)))


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

Issue: Macro call that should be transformed by FAIL

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

Output:
(defmacro fail (form &optional (type 'error) description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(fail ,form ,type)
                   :value-form '(capture-error ,form)
                   :body (lambda () (capture-error ,form ,(maybe-unquote type)))
                   :expected ',(maybe-unquote type)
                   :comparison 'typep
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))


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

Issue: Macro call that should be transformed by SIF

Input: (sif nil (progn))

Output:
(defmacro sif (test then &optional else)
  "Like IF, except binds the test form to IT (via SYMBOL-MACROLET) for
the scope of the then and else expressions. IT can be set with SETF"
  `(symbolic if ,test ,then ,else))


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

Issue: Macro call that should be transformed by XML

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

Output:
(defmacro xml (&rest tags)
  `(with-doctype :xml
     (loop for tag in ',tags
           append (tag->string tag))))


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

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

Input: (-<>> nil nil)

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


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

Issue: Macro call that should be transformed by DISTINCT-ON

Input: (distinct-on nil)

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


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

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

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

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


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

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

Input:
(c_in
  nil
  (progn))

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


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

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

Input:
(all-values
  nil
  nil)

Output: (defmacro ALL-VALUES ...)


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

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

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

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


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

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

Input: (example)

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


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

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

Input: (xor nil)

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


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

Problem: Macro call that should be transformed by PSETF

Input: (psetf)

Output: (defmacro PSETF ...)


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

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

Input:
(dowhile-it nil
  (progn))

Output:
(defmacro dowhile-it (test &body body)
  "Like DOWHILE. IT is bound to TEST."
  `(do ((it ,test ,test))
       ((not it))
     ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(shift-incf nil nil)

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

Input: (shift-incf nil nil)

Output: (defmacro SHIFT-INCF ...)


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

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

Input: (cond-bind nil)

Output: (defmacro COND-BIND ...)


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

Pattern to recognize: Macro call that should be transformed by PS-INLINE

Input: (ps-inline 'lol-gen::some-name)

Output: (defmacro PS-INLINE ...)


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

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

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

Output:
(defmacro c-lambda (&body body)
  `(c-lambda-var (slot-c) ,@body))


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

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

Input:
(sum-of nil
  (progn))

Output: (defmacro SUM-OF ...)


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

What needs to change: Macro call that should be transformed by STATIC-LOAD-TIME-VALUE

Input: (static-load-time-value 'lol-gen::some-name)

Output:
(defmacro static-load-time-value
    (form &optional (read-only-p nil read-only-p-supplied?))
  "Like `load-time-value', but signals an error if it cannot preserve identity.

On close reading of the standard, in a function that is evaluated but
not compiled, it is permissible for implementations to repeatedly
execute a `load-time-value' form, and in fact some implementations do
this \(including, at the time of writing, ABCL, CLISP, Allegro and
LispWorks).

When `static-load-time-value' is compiled, it behaves exactly like
`load-time-value'. Otherwise it conducts a run-time check to ensure
that `load-time-value' preserves identity."
  ;; Thanks to Jean-Philippe Paradis and Michał Herda for helping to
  ;; diagnose and treat the problem here.
  (if *compile-file-truename*
      `(load-time-value ,form
                        ,@(and read-only-p-supplied? (list read-only-p)))
      `(progn
         (flet ((fn () (load-time-value (random most-positive-fixnum))))
           (declare (dynamic-extent #'fn) (ignorable #'fn)
                    #+LispWorks (notinline fn))
           ;; Do the actual test out of line.
           (test-load-time-value #'fn ',form ',read-only-p))
         (load-time-value ,form
                          ,@(and read-only-p-supplied? (list read-only-p))))))


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

Problem: Macro call that should be transformed by ALAMBDA

Input: (alambda nil)

Output:
(defmacro alambda (lambda-list &body body)
  "Like LAMBDA, except that SELF is bound to the resulting function (via LABELS)
within BODY."
  `(labels ((self ,lambda-list ,@body))
     #'self))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(define-type-dispatch nil
    nil)

Problem: Macro call that should be transformed by DEFINE-TYPE-DISPATCH

Input:
(define-type-dispatch nil
    nil)

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


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

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

Input: (dict-of nil (progn))

Output: (defmacro DICT-OF ...)


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

Issue: Macro call that should be transformed by AS-OBJECT-MEMBER

Input: (as-object-member 'lol-gen::some-name)

Output:
(defmacro as-object-member ((key &optional (stream '*json-output*))
                             &body body)
  "BODY should be a program which writes exactly one JSON datum to
STREAM.  AS-OBJECT-MEMBER ensures that the datum is properly formatted
as a Member of an Object, i. e. preceded by the (encoded) KEY and
colon, and separated by comma from any preceding or following Member."
  `(progn
     (next-aggregate-member 'object ,stream)
     (let ((key (encode-json-to-string ,key)))
       (if (char= (aref key 0) #\")
           (progn (write-string key ,stream) nil)
           (encode-json key ,stream)))
     (write-char #\: ,stream)
     ,@body))


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

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

Input:
(with-column-writers nil
  :key
  nil)

Output:
(defmacro with-column-writers ((&rest defs) &body body)
  "Provides control over the way get-dao, select-dao, and query-dao read values
from the database. This is not commonly needed, but can be used to reduce the
amount of queries a system makes. writers should be a list of alternating
column names (strings or symbols) and writers, where writers are either
symbols referring to a slot in the objects, or functions taking two arguments ―
an instance and a value ― which can be used to somehow store the value in the
new instance. When any DAO-fetching function is called in the body, and
columns matching the given names are encountered in the result, the writers
are used instead of the default behaviour (try and store the value in the slot
that matches the column name).

An example of using this is to add some non-column slots to a DAO class, and
use query-dao within a with-column-writers form to pull in extra information
about the objects, and immediately store it in the new instances."
  `(let ((*custom-column-writers*
           (append (list ,@(loop :for (field writer) :on defs :by #'cddr
                                 :collect `(cons (to-sql-name ,field nil) ,writer)))
                   *custom-column-writers*)))
     ,@body))


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

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

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

Output: (defmacro KNOWN? ...)


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

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

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

Output: (defmacro COND-> ...)


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

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

Input:
(receive nil
    nil)

Output:
(defmacro receive (formals expr &body body)
  "Stricter version of `multiple-value-bind'.

Use `receive' when you want to enforce that EXPR should return a
certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many
values -- no more and no less -- as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at
least as many values as there are VARS, and any further values are
bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values
returned by EXPR, as if by `multiple-value-list'.

From Scheme (SRFI-8)."
  ;; It's probably not worth stack-allocating the thunk.
  (cond ((null formals)
         `(multiple-value-call
              (lambda ()
                ,@body)
            ,expr))
        ((atom formals)
         ;; This could also be written:
         #+(or) `(let ((,formals (multiple-value-list ,expr)))
                   ,@body)
         ;; But I want it to be possible to declare FORMALS to have
         ;; dynamic extent, and most Lisps support that for &rest
         ;; lists.
         `(multiple-value-call
              (lambda (&rest ,formals)
                ,@body)
            ,expr))
        ((proper-list-p formals)
         (when (intersection formals lambda-list-keywords)
           (error "Lambda list keywords in formals: ~a" formals))
         `(multiple-value-call
              (lambda ,formals
                ,@body)
            ,expr))
        (t (let* ((last (last formals))
                  (vars (append (butlast formals)
                                (list (car last))))
                  (rest (cdr last)))
             (when (intersection (cons rest vars) lambda-list-keywords)
               (error "Lambda list keywords in formals: ~a" formals))
             `(multiple-value-call
                  (lambda (,@vars &rest ,rest)
                    ,@body)
                ,expr)))))


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

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

Input: (dict-of 'lol-gen::some-name)

Output: (defmacro DICT-OF ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(pprint-coalton-codegen-ast
  common-lisp:nil
  :key
  common-lisp:nil)

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

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

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


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

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

Input: (is-type nil (progn))

Output:
(defmacro is-type (got expected-type &optional desc)
  (with-gensyms (duration result)
    (once-only (desc expected-type)
      `(with-catching-errors (:description ,desc :expected ,expected-type)
         (with-duration ((,duration ,result) ,got)
           (test ,result ,expected-type ,desc
                 :duration ,duration
                 :got-form ',got
                 :test-fn #'typep
                 :report-expected-label "be a type of"))))))


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

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

Input: (documentation common-lisp:nil)

Output: (defmacro DOCUMENTATION ...)


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

Issue: Macro call that should be transformed by ITER

Input:
(iter
  nil
  :key
  nil)

Output: (defmacro ITER ...)


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

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

Input:
(resolving
  nil)

Output: (defmacro RESOLVING ...)


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

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

Input: (define-layered-class nil)

Output: (defmacro DEFINE-LAYERED-CLASS ...)


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

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

Input: (and nil)

Output: (defmacro AND ...)


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

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

Input:
(defpattern nil
    (progn))

Output:
(defmacro defpattern (name lambda-list &body body)
  "Defines a derived pattern specifier named NAME. This is analogous
to DEFTYPE.

Examples:

    ;; Defines a LIST pattern.
    (defpattern list (&rest args)
      (when args
        `(cons ,(car args) (list ,@(cdr args)))))"
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (pattern-expand-function ',name) (lambda ,lambda-list ,@body))))


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

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

Input: (nix)

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

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

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


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

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

Input:
(cond-every
  nil
  nil)

Output:
(defmacro cond-every (&body clauses)
  "Like `cond', but instead of stopping after the first clause that
succeeds, run all the clauses that succeed.

Return the value of the last successful clause.

If a clause begins with `cl:otherwise', it runs only if no preceding
form has succeeded.

Note that this does *not* do the same thing as a series of `when'
forms: `cond-every' evaluates *all* the tests *before* it evaluates
any of the forms.

From Zetalisp."
  (let* ((otherwise-clause (find 'otherwise clauses :key #'car))
         (test-clauses (remove otherwise-clause clauses))
         (temps (make-gensym-list (length test-clauses))))
    `(let* ,(loop for temp in temps
                  for (test . nil) in test-clauses
                  collect `(,temp ,test))
       ;; Work around Iterate bug. See
       ;; <https://gitlab.common-lisp.net/iterate/iterate/-/issues/11>.
       (if (or ,@temps)
           ,(with-gensyms (ret)
              `(let (,ret)
                 ,@(loop for temp in temps
                         for (nil . body) in test-clauses
                         collect `(when ,temp
                                    (setf ,ret
                                          ,(if (null body)
                                               temp
                                               `(progn ,@body)))))
                 ,ret))
           (progn ,@(rest otherwise-clause))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(|^K1|)

Issue: Macro call that should be transformed by ^K1

Output: (defmacro ^k1 () `(kid1 self))


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

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

Input: (collect-alist nil (progn))

Output: (defmacro COLLECT-ALIST ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(reduced-typecase nil (progn))

Issue: Macro call that should be transformed by REDUCED-TYPECASE

Input: (reduced-typecase nil (progn))

Output: (defmacro REDUCED-TYPECASE ...)


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

Problem: Macro call that should be transformed by C_1

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

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


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

Issue: Macro call that should be transformed by ETYPECASE

Input: (etypecase nil (progn))

Output: (defmacro ETYPECASE ...)


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

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

Input:
(all-values
  nil)

Output: (defmacro ALL-VALUES ...)


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

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

Input: (with-implicit-conversion 'lol-gen::some-name)

Output: (defmacro WITH-IMPLICIT-CONVERSION ...)


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

What needs to change: Macro call that should be transformed by INCF-POINTER

Input: (incf-pointer nil (progn))

Output: (defmacro INCF-POINTER ...)


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

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

Input: (cond-> nil)

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


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

Write a macro that addresses: Macro call that should be transformed by DEF-FIXTURE

Input:
(def-fixture nil
    :key
  nil)

Output:
(defmacro def-fixture (name (&rest args) &body body)
  "Defines a fixture named NAME. A fixture is very much like a
macro but is used only for simple templating. A fixture created
with DEF-FIXTURE is a macro which can use the special macrolet
&BODY to specify where the body should go.

See Also: WITH-FIXTURE
"
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (get-fixture ',name) (cons ',args ',body))
     ',name))


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

Issue: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE

Input: (define-screamer-package nil)

Output:
(defmacro define-screamer-package (defined-package-name &body options)
  "Convenience wrapper around DEFPACKAGE. Passes its argument directly
to DEFPACKAGE, and automatically injects two additional options:

    \(:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)
    \(:use :cl :screamer)"
  `(defpackage ,defined-package-name
     ,@options
     (:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)
     (:use :cl :screamer)))


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

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

Input:
(with-dot nil
  :key
  nil)

Output:
(defmacro with-dot (() &body body)
  `(progn ,@(replace-dot-calls body)))


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

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

Input: (query-dao nil (progn))

Output:
(defmacro query-dao (type query &rest args)
  "Execute the given query (which can be either a string or an S-SQL expression)
and return the result as DAOs of the given type. If the query contains
placeholders ($1, $2, etc) their values can be given as extra arguments. The
names of the fields returned by the query must either match slots in the DAO
class, or be bound through with-column-writers."
  `(query-dao% ,type ,(real-query query) (dao-row-reader (find-class ,type)) ,@args))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(ignore-some-conditions nil
  (progn))

What needs to change: Macro call that should be transformed by IGNORE-SOME-CONDITIONS

Input:
(ignore-some-conditions nil
  (progn))

Output:
(defmacro ignore-some-conditions ((&rest conditions) &body body)
  "Similar to CL:IGNORE-ERRORS but the (unevaluated) CONDITIONS
list determines which specific conditions are to be ignored."
  `(handler-case
       (progn ,@body)
     ,@(loop for condition in conditions collect
             `(,condition (c) (values nil c)))))


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

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

Input: (ensure-gethash nil :key 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:
Define a macro that eliminates this repetitive pattern:
(n^ nil)

Issue: Macro call that should be transformed by N^

Input: (n^ nil)

Output:
(defmacro n^ (type)
  `(nearest self ,type))


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

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

Input:
(with-array nil
  :key
  nil)

Output:
(defmacro with-array ((&optional (stream '*json-output*)) &body body)
  "Open a JSON Array, run BODY, then close the Array.  Inside the BODY,
AS-ARRAY-MEMBER or ENCODE-ARRAY-MEMBER should be called to encode
Members of the Array."
  `(with-aggregate (array #\[ #\] ,stream) ,@body))


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

What needs to change: Macro call that should be transformed by MAKE-WINDOW-OR-INSTANCE

Input: (make-window-or-instance nil nil)

Output: (defmacro MAKE-WINDOW-OR-INSTANCE ...)


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

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

Input:
(accase nil
  (progn))

Output:
(defmacro accase (keyform &body cases)
  "Like CCASE, except binds the result of the keyform to IT (via LET) for the
scope of the cases. Unlike CCASE, the keyform/place doesn't receive new values
possibly stored with STORE-VALUE restart; the new value is received by IT."
  `(anaphoric ccase ,keyform ,@cases))


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

Problem: Macro call that should be transformed by FM!

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

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


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

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

Input: (with-truncated-stack nil)

Output:
(defmacro with-truncated-stack (() &body body)
  `(stack-truncator (lambda () ,@body)))


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

Write a macro that addresses: Macro call that should be transformed by ADVISABLE-LAMBDA

Input: (advisable-lambda nil)

Output: (defmacro ADVISABLE-LAMBDA ...)


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

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

Input:
(select nil
  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:
You are a Common Lisp macro expert. Given this code pattern:
(mvlet nil)

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

Input: (mvlet nil)

Output:
(defmacro mvlet ((&rest bindings) &body body)
  "Parallel (`let'-like) version of `mvlet*'."
  (cond ((null bindings)
         `(locally ,@body))
        ((null (rest bindings))
         (let* ((bindings (canonicalize-bindings bindings))
                (b (first bindings)))
           `(multiple-value-bind ,(butlast b) ,(lastcar b)
              ,@body)))
        ((every #'simple-binding-p bindings)
         `(let ,bindings
            ,@body))
        (t (let* ((bindings (canonicalize-bindings bindings))
                  (binds
                    (mapcar #'butlast bindings))
                  (exprs
                    (mapcar #'lastcar bindings))
                  (temp-binds
                    (loop for vars in binds
                          collect (mapcar #'string-gensym vars)))
                  (temp-bindings
                    (loop for temp-bind in temp-binds
                          for expr in exprs
                          collect (append temp-bind (list expr))))
                  (rebindings
                    (loop for vars in binds
                          for temp-vars in temp-binds
                          append (loop for var in vars
                                       for temp-var in temp-vars
                                       collect (list var temp-var)))))
             `(mvlet* ,temp-bindings
                (let ,rebindings
                  ,@body))))))


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

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

Input:
(with-inactive-layers nil
  nil)

Output: (defmacro WITH-INACTIVE-LAYERS ...)


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

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

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

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


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

Issue: Macro call that should be transformed by STYPECASE

Input:
(stypecase nil
  :key
  nil)

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


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

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

Input: (dccase nil)

Output:
(defmacro dccase (keyform &body clauses)
  "DCCASE is a combination of CCASE and DESTRUCTURING-BIND.
   KEYFORM must evaluate to a CONS.

   Clauses are of the form:

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

   The clause whose CASE-KEYS matches CAR of KEY, as if by CCASE,
   is selected, and FORMs are then executed with CDR of KEY is destructured and
   bound by the DESTRUCTURING-LAMBDA-LIST."
  (expand-destructuring-case keyform clauses 'ccase))


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

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

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

Output:
(defmacro bgo (msg)
  `(break "BGO ~a" ',msg))


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

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

Input:
(lambda* nil
  nil)

Output: (defmacro LAMBDA* ...)


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

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

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

Output:
(defmacro doseq (name/seq &body body)
  "Iterate over the elements of a single sequence SEQUENCE.

   Same as DO-SEQUENCES but for the special case of iterating over a
   single sequence.

   The macro arguments can be in one of the following two forms:

    1. (NAME (ELEMENT SEQUENCE &REST ARGS) &BODY BODY)

    2. ((ELEMENT SEQUENCE &REST ARGS) &BODY BODY)

   NAME is the block name, NIL if not given.

   ELEMENT is the variable to which each element of the sequence is
   bound.

   SEQUENCE is the sequence, with ARGS being the remaining arguments
   passed to the ITERATOR function.

   BODY is the list of forms evaluated on each iteration."

  (let-if ((name name/seq)
           (seq (first body) name/seq)
           (body (rest body) body))
      (symbolp name/seq)

    (destructuring-bind (element sequence &rest args) seq
      `(do-sequences ,name
         ((,element ,sequence ,@args))
         ,@body))))


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

Problem: Macro call that should be transformed by FN*

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

Output:
(defmacro fn* (form &environment env)
  (fn*-internals form env))


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

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

Output: (defmacro ->> ...)


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

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

Input: (removef nil (progn))

Output: (defmacro REMOVEF ...)


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

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

Input:
(fbind nil
  (progn))

Output:
(defmacro fbind (bindings &body body &environment *lexenv*)
  "Binds values in the function namespace.

That is,
     (fbind ((fn (lambda () ...))))
     ≡ (flet ((fn () ...))),

except that a bare symbol in BINDINGS is rewritten as (symbol
symbol)."
  (setf bindings (expand-fbindings bindings))
  (unless bindings
    (return-from fbind `(locally ,@body)))
  ;; When possible (if the binding expands to a simple
  ;; let-over-lambda), we hoist the bindings to the top and bind
  ;; the lambda directly with flet.

  ;; Failing that, if we know that the function is never directly
  ;; dereferenced with sharp-quote, we can bind with `macrolet'
  ;; instead of `flet', leaving no runtime overhead vs. `funcall'.
  (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))
           (macro-vars
            (merely-syntactic-functions (mapcar #'first bindings)
                                        body
                                        *lexenv*))
           (vars  (mapcar #'first bindings))
           (exprs (mapcar #'second bindings))
           (temps (mapcar #'string-gensym vars))
           (body decls (parse-body body)))
    `(let ,env
       ,@(unsplice (and env-decls `(declare ,@env-decls)))
       (comment "fbind: Hidden variable bindings to close over.")
       (let ,(loop for temp in temps
                   for expr in exprs
                   collect `(,temp (ensure-function ,expr)))
         ,@(when temps
             (unsplice
              `(declare (function ,@temps))))
         (comment "fbind: Hidden variable bindings for function values.")
         (flet (,@(loop for (name lambda) in lambdas
                        collect `(,name ,@(cdr lambda)))
                ,@(loop for var in vars
                        for temp in temps
                        unless (member var macro-vars)
                          collect (build-bind/ftype var temp decls env)))
           #-sbcl (declare (inline ,@(set-difference vars macro-vars)))
           ,@decls
           (comment "fbind: Functions that might be sharp-quoted.")
           (macrolet (,@(loop for var in vars
                              for temp in temps
                              when (member var macro-vars)
                                collect `(,var
                                          (&rest args)
                                          (list* 'funcall ',temp args))))
             (comment "fbind: Macros for functions provably never sharp-quoted.")
             ,@body))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(named-lambda nil
    (progn))

Issue: Macro call that should be transformed by NAMED-LAMBDA

Input:
(named-lambda nil
    (progn))

Output:
(defmacro named-lambda (name lambda-list &body body)
  "Expands into a lambda-expression within whose BODY NAME denotes the
   corresponding function."
  `(labels ((,name ,lambda-list ,@body))
     #',name))


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

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

Input: (call-method nil)

Output: (defmacro CALL-METHOD ...)


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

Problem: Macro call that should be transformed by DROP-TABLE

Input: (drop-table 'lol-gen::some-name)

Output:
(defmacro drop-table (table &key if-exists)
  `(make-statement :drop-table
                   ,(expand-expression table) :if-exists ,if-exists))


Instruction:
Define a macro that eliminates this repetitive pattern:
(unwind-protect nil
    :key
  nil)

Issue: Macro call that should be transformed by UNWIND-PROTECT

Input:
(unwind-protect nil
    :key
  nil)

Output: (defmacro UNWIND-PROTECT ...)


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

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

Input: (nunionf nil (progn))

Output: (defmacro NUNIONF ...)


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

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

Input:
(define-values nil
  nil)

Output:
(defmacro define-values (values &body (expr))
  "Like `def', but for multiple values.
Each variable in VALUES is given a global, lexical binding, as with
`def', then set all at once, as with `multiple-value-setq'."
  `(progn
     ,@(loop for v in values collect `(def ,v nil))
     (setf (values ,@values) ,expr)
     (values ,@(loop for v in values collect `(quote ,v)))))


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

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

Input: (boolean-unless nil)

Output:
(defmacro boolean-unless (branch &body body &environment env)
  "Includes some forms based on whether a macroexpand-time branch is false. The
first argument must be a symbol naming a branch in the lexically enclosing
WITH-BOOLEAN form.
\
It is an error to use this macro outside the lexical environment established by
WITH-BOOLEAN."
  (cond (*boolean-bypass*
         `(unless ,branch ,@body))
        ((not (member branch (macroexpand-1 '%all-branches% env)))
         (missing-branch branch))
        ((not (macroexpand-1 '%in-branching% env))
         (conditional-error 'unless))
        ((member branch (macroexpand-1 '%true-branches% env))
         `(progn))
        ((= 0 (length body))
         `(progn))
        ((= 1 (length body))
         (car body))
        (t `(progn ,@body))))


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

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

Input: (destructuring-match nil)

Output: (defmacro DESTRUCTURING-MATCH ...)


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

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

Input:
(defmethod nil
  :key
  nil)

Output: (defmacro DEFMETHOD ...)


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

Issue: Macro call that should be transformed by APROG1

Input: (aprog1 nil)

Output:
(defmacro aprog1 (first &body rest)
  "Binds IT to the first form so that it can be used in the rest of the
forms. The whole thing returns IT."
  `(anaphoric prog1 ,first ,@rest))


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

Problem: Macro call that should be transformed by CTYPECASE

Input: (ctypecase nil)

Output: (defmacro CTYPECASE ...)


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

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

Input:
(v-defstruct nil
    (progn))

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


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

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

Input: (initially nil (progn))

Output: (defmacro INITIALLY ...)


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

Problem: Macro call that should be transformed by NODELIST

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

Output: (defmacro NODELIST ...)


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

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

Input: (f-find nil :key nil)

Output:
(defmacro f-find (synapse-id sought where)
  `(call-f-find ,synapse-id ,sought ,where))


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

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

Input: (with-integrity nil nil)

Output:
(defmacro with-integrity ((&optional opcode defer-info debug) &rest body)
  (declare (ignorable debug))
  (when opcode
    (assert (find opcode *ufb-opcodes*) ()
      "Invalid opcode for with-integrity: ~a. Allowed values: ~a" opcode *ufb-opcodes*))
  `(call-with-integrity ,opcode ,defer-info
     (lambda (opcode defer-info)
       (declare (ignorable opcode defer-info))
       ;;;       ,(when debug
       ;;;          `(trc "integrity action entry" opcode defer-info ',body))
       ;;;       (when *c-debug*
       ;;;         (when (eq opcode :change)
       ;;;           (trc "-------w/integ :change go--------------->:" defer-info)))
       ,@body)
     nil
     #+noway (when *c-debug* ',body)))


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

Write a macro that addresses: Macro call that should be transformed by FAIL-COMPILE

Input: (fail-compile 'lol-gen::some-name)

Output:
(defmacro fail-compile (form &optional (type 'error) description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(fail-expansion ,form)
                   :value-form '(nth-value 3 (try-compile ',form ',type))
                   :body (lambda () (nth-value 3 (try-compile ',form ',type)))
                   :expected ',(maybe-unquote type)
                   :comparison 'typep
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))


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

Problem: Macro call that should be transformed by SKIP

Input:
(skip nil
  nil)

Output:
(defmacro skip (desc &body tests)
  `(with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))
     ,@tests))


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

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

Input:
(c?n-until nil
  (progn))

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


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

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

Input: (->* nil :key nil)

Output: (defmacro ->* ...)


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

Problem: Macro call that should be transformed by PRODUCING

Input: (producing)

Output: (defmacro PRODUCING ...)


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

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

Input: (define-processor)

Output:
(defmacro define-processor (&key name file-reader string-reader extra-traverser)
  (let ((extras (loop for i in extra-traverser collect
			 `(traverser (make-instance ',i) tree 0))))
    `(defun ,name (args)
       (multiple-value-bind (input output debug) (parse-cmdline args ,string-reader)
	 (when input
	   (let ((tree nil)
		 (pprint (make-instance 'pretty-printer)))
	     (setf tree (,file-reader input))
	     ,@extras
	     (if output
		 (with-open-file
		     (stream output :direction :output
				    :if-exists :supersede
				    :if-does-not-exist :create)
		   (setf (slot-value pprint 'stream) stream)
		   (traverser pprint tree 0))
		 (progn
		   (setf (slot-value pprint 'stream) *standard-output*)
		   (traverser pprint tree 0)
		   (format t "~&")))
	     ))))))


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

Problem: Macro call that should be transformed by WITH-CONTRACTS-ENABLED

Input: (with-contracts-enabled nil)

Output:
(defmacro with-contracts-enabled
    ((&rest args &key invariants preconditions postconditions) &body body)
  "Enables/disables contracts for the extent of this form, restoring them to
   their prior values upon exit."
  (declare (ignore invariants preconditions postconditions))
  (let ((enabled-contracts (gensym "ENABLED-CONTRACTS-")))
    `(let ((,enabled-contracts (enabled-contracts)))
       (unwind-protect
            (progn (enable-contracts ,@args)
                   ,@body)
         (apply #'enable-contracts ,enabled-contracts)))))


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

Write a macro that addresses: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE

Input: (on-duplicate-key-update nil :key nil)

Output:
(defmacro on-duplicate-key-update (&rest args)
  `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(collecting-into-and-returning 'lol-gen::some-name)

Issue: Macro call that should be transformed by COLLECTING-INTO-AND-RETURNING

Input: (collecting-into-and-returning 'lol-gen::some-name)

Output: (defmacro COLLECTING-INTO-AND-RETURNING ...)


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

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

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

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


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

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

Input:
(define-alias nil
    (progn))

Output: (defmacro DEFINE-ALIAS ...)


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

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

Input:
(defpattern nil
    :key
  nil)

Output:
(defmacro defpattern (name lambda-list &body body)
  "Defines a derived pattern specifier named NAME. This is analogous
to DEFTYPE.

Examples:

    ;; Defines a LIST pattern.
    (defpattern list (&rest args)
      (when args
        `(cons ,(car args) (list ,@(cdr args)))))"
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (pattern-expand-function ',name) (lambda ,lambda-list ,@body))))


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

Write a macro that addresses: Macro call that should be transformed by MAKE-KID

Input: (make-kid nil nil)

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(cmatch* common-lisp:nil
  common-lisp:nil)

Issue: Macro call that should be transformed by CMATCH*

Input:
(cmatch* common-lisp:nil
  common-lisp:nil)

Output:
(defmacro cmatch* (whats &body clauses)
  #.+match*-doc+
  (let ((temps (make-gensyms whats "OTHERWISE")))
    `(match2* ,whats
       ,@clauses
       (,temps
        (cerror "continue" 'match-error :pattern ',clauses :values (list ,@temps))))))


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

Problem: Macro call that should be transformed by GATHERING

Input:
(gathering nil
  (progn))

Output: (defmacro GATHERING ...)


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

Problem: Macro call that should be transformed by PSETQ

Input: (psetq nil nil)

Output: (defmacro PSETQ ...)


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

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

Input:
(mvlet* nil
  nil)

Output:
(defmacro mvlet* ((&rest bindings) &body body &environment env)
  "Expand a series of nested `multiple-value-bind' forms.

`mvlet*' is similar in intent to Scheme’s `let-values', but with a
different and less parenthesis-intensive syntax. Each binding is a
list of

    (var var*... expr)

A simple example should suffice to show both the implementation and
the motivation:

    (defun uptime (seconds)
      (mvlet* ((minutes seconds (truncate seconds 60))
               (hours minutes (truncate minutes 60))
               (days hours (truncate hours 24)))
        (declare ((integer 0 *) days hours minutes seconds))
        (fmt \"~d day~:p, ~d hour~:p, ~d minute~:p, ~d second~:p\"
             days hours minutes seconds)))

Note that declarations work just like `let*'."
  (cond ((null bindings)
         `(locally ,@body))
        ((every #'simple-binding-p bindings)
         `(let* ,bindings ,@body))
        (t (multiple-value-bind (body decls)
               (parse-body body)
             (let* ((bindings (canonicalize-bindings bindings))
                    (mvbinds (member-if-not #'simple-binding-p bindings))
                    (simple-binds (ldiff bindings mvbinds)))
               (if simple-binds
                   (multiple-value-bind (local other)
                       (partition-declarations (mapcar #'car simple-binds) decls env)
                     `(let* ,simple-binds
                        ,@local
                        (mvlet* ,mvbinds
                          ,@other
                          ,@body)))
                   (let* ((vars (butlast (car bindings)))
                          (expr (lastcar (car bindings))))
                     (multiple-value-bind (local other)
                         (partition-declarations vars decls env)
                       `(multiple-value-bind ,vars
                            ,expr
                          ,@local
                          (mvlet* ,(cdr bindings)
                            ,@other
                            ,@body))))))))))


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

Problem: Macro call that should be transformed by APROG1

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

Output:
(defmacro aprog1 (first &body rest)
  "Binds IT to the first form so that it can be used in the rest of the
forms. The whole thing returns IT."
  `(anaphoric prog1 ,first ,@rest))


Instruction:
Define a macro that eliminates this repetitive pattern:
(|GETSET#| nil :key nil)

Issue: Macro call that should be transformed by GETSET#

Input: (|GETSET#| nil :key nil)

Output: (defmacro GETSET# ...)


Instruction:
Generate a defmacro form that transforms code like this:
(collect-and nil)

Pattern to recognize: Macro call that should be transformed by COLLECT-AND

Input: (collect-and nil)

Output: (defmacro COLLECT-AND ...)


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

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

Input:
(lret nil
  nil)

Output:
(defmacro lret ((&rest bindings) &body body)
  "Return the initial value of the last binding in BINDINGS. The idea
is to create something, initialize it, and then return it.

    (lret ((x 1)
           (y (make-array 1)))
      (setf (aref y 0) x))
    => #(1)

Note that the value returned is the value initially bound. Subsequent
assignments are ignored.

    (lret ((x 1))
      (setf x 2))
    => 1

Furthermore, on Lisps that support it, the variable may be made
read-only, making assignment a compiler-time error.

`lret' may seem trivial, but it fufills the highest purpose a macro
can: it eliminates a whole class of bugs (initializing an object, but
forgetting to return it).

Cf. `aprog1' in Anaphora."
  `(lret-aux let ,bindings
     ,@body))


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

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

Input: (shiftf nil (progn))

Output: (defmacro SHIFTF ...)


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

Problem: Macro call that should be transformed by EXPORT-STRUCTURE

Input:
(export-structure
  'lol-gen::some-name)

Output: (defmacro EXPORT-STRUCTURE ...)


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

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

Input: (collect nil (progn))

Output: (defmacro COLLECT ...)


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

Problem: Macro call that should be transformed by FAIL

Input: (fail)

Output:
(defmacro fail (&rest message-args)
  "Simply generate a FAIL."
  `(process-failure ',message-args
                    ,@message-args))


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

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

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

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


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

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

Input: (distinct-on 'lol-gen::some-name)

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


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

Problem: Macro call that should be transformed by EXAMPLE

Input:
(example
  nil)

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


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

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

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

Output:
(defmacro dccase (keyform &body clauses)
  "DCCASE is a combination of CCASE and DESTRUCTURING-BIND.
   KEYFORM must evaluate to a CONS.

   Clauses are of the form:

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

   The clause whose CASE-KEYS matches CAR of KEY, as if by CCASE,
   is selected, and FORMs are then executed with CDR of KEY is destructured and
   bound by the DESTRUCTURING-LAMBDA-LIST."
  (expand-destructuring-case keyform clauses 'ccase))


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

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

Input:
(v-defun nil
    (progn))

Output:
(defmacro v-defun (name args &body body)
  `(define-vari-function ,name ,args ,@body))


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

Issue: Macro call that should be transformed by DEF-TEST

Input:
(def-test nil
    nil)

Output:
(defmacro def-test (name (&key depends-on (suite '*suite* suite-p) fixture
                            (compile-at *default-test-compilation-time*) profile)
                    &body body)
  "Create a test named NAME.

NAME is the symbol which names the test.

DEPENDS-ON is a list of the form:

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

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

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

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

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

FIXTURE specifies a fixture to wrap the body in.

If PROFILE is T profiling information will be collected as well."
  (check-type compile-at (member :run-time :definition-time))
  (multiple-value-bind (forms decls docstring)
      (parse-body body :documentation t :whole name)
    (let* ((description (or docstring ""))
           (body-forms (append decls forms))
           (suite-form (if suite-p
                           `(get-test ',suite)
                           (or suite '*suite*)))
           (effective-body (if fixture
                               (destructuring-bind (name &rest args)
                                   (ensure-list fixture)
                                 `((with-fixture ,name ,args ,@body-forms)))
                               body-forms)))
      `(progn
         (register-test ',name ,description ',effective-body ,suite-form ',depends-on ,compile-at ,profile)
         (when *run-test-when-defined*
           (run! ',name))
         ',name))))


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

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

Input:
(acond
  nil
  nil)

Output: (defmacro ACOND ...)


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

Pattern to recognize: Macro call that should be transformed by NSPLICE-SEQF

Input: (nsplice-seqf nil (progn))

Output: (defmacro NSPLICE-SEQF ...)


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

Issue: Macro call that should be transformed by CALLF2

Input: (callf2 nil :key nil)

Output:
(defmacro callf2 (function arg1 place &rest args)
  "Like CALLF, but with the place as the second argument."
  `(callf (curry ,function ,arg1) ,place ,@args))


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

Problem: Macro call that should be transformed by SEND

Input: (send nil)

Output: (defmacro SEND ...)


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

What needs to change: Macro call that should be transformed by MODF-EVAL

Input: (modf-eval)

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


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

What needs to change: Macro call that should be transformed by SHIFT-DECF

Input: (shift-decf 'lol-gen::some-name)

Output: (defmacro SHIFT-DECF ...)


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

Pattern to recognize: Macro call that should be transformed by COLLECT-NTH

Input: (collect-nth nil :key nil)

Output: (defmacro COLLECT-NTH ...)


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

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

Input: (fm-collect nil)

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


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

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

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

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


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

Issue: Macro call that should be transformed by OR

Input: (or nil :key nil)

Output: (defmacro OR ...)


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

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

Input:
(and-let* nil
  (progn))

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

Each clause should have one of the following forms:

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

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

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

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

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


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

Write a macro that addresses: Macro call that should be transformed by EVAL-ALWAYS

Input: (eval-always)

Output: (defmacro EVAL-ALWAYS ...)


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

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

Input: (when-it 'lol-gen::some-name)

Output:
(defmacro when-it (test &body body)
  "Like WHEN. IT is bound to TEST."
  `(let ((it ,test))
     (when it
       ,@body)))


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

Problem: Macro call that should be transformed by THE-KIDS

Input: (the-kids nil nil)

Output:
(defmacro the-kids (&rest kids)
  `(let ((*parent* self))
     (packed-flat! ,@kids)))


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

Problem: Macro call that should be transformed by GEN-LAMBDA

Input:
(gen-lambda nil
  (progn))

Output:
(defmacro gen-lambda (params &body rest)
  "Version of lambda that wraps the anonymous function in an instance of the basic-generator class. This allows the lambda to be identified as a generator by its type. Basic-generator objects are derived from funcallable-standard-class, therefore they can be called as functions."
  `(let ((values-handler (create-values-handler)))
     (declare (ignorable values-handler))
     (make-instance
      'basic-generator
      :function (lambda ,params ,@rest))))


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

Pattern to recognize: Macro call that should be transformed by DEFMACRO-CLAUSE

Input: (defmacro-clause 'lol-gen::some-name)

Output:
(defmacro defmacro-clause (clause-template &body body)
  "Create your own iterate clauses"
  (define-clause 'defmacro clause-template body nil))


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

Issue: Macro call that should be transformed by ITH-VALUE

Input: (ith-value nil nil)

Output: (defmacro ITH-VALUE ...)


Instruction:
Generate a defmacro form that transforms code like this:
(multiple-value-ematch nil
  nil)

Pattern to recognize: Macro call that should be transformed by MULTIPLE-VALUE-EMATCH

Input:
(multiple-value-ematch nil
  nil)

Output:
(defmacro multiple-value-ematch (values-form &body clauses)
  "Same as MULTIPLE-VALUE-MATCH, except MATCH-ERROR will be raised if
not matched."
  (let* ((values (gensym "VALUES"))
         (else `(error 'match-error
                       :values ,values
                       :patterns ',(mapcar #'car clauses))))
    ;; FIXME: remove allocations
    `(let ((,values (multiple-value-list ,values-form)))
       ,(compile-multiple-value-match `(values-list ,values) clauses else))))


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

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

Input:
(define-definition-resolver nil
    nil)

Output:
(defmacro define-definition-resolver (name args &body body)
  `(progn (setf (definition-resolver ',name)
                (lambda ,args ,@body))
          ',name))


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

Problem: Macro call that should be transformed by LAMBDA-EMATCH1

Input:
(lambda-ematch1 common-lisp:nil
  (common-lisp:progn))

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


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

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

Input: (flet* nil)

Output: (defmacro FLET* ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(fm-otherv? nil)

Write a macro that addresses: Macro call that should be transformed by FM-OTHERV?

Input: (fm-otherv? nil)

Output:
(defmacro fm-otherv? (md-name &optional (starting 'self) (global-search t))
  `(fm-other-v ,md-name ,starting ,global-search))


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

Problem: Macro call that should be transformed by LRET*

Input: (lret* nil)

Output:
(defmacro lret* ((&rest bindings) &body body)
  "Cf. `lret'."
  `(lret-aux let* ,bindings
     ,@body))


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

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

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

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:
Define a macro that eliminates this repetitive pattern:
(gen-lambda-with-sticky-stop nil (progn))

Issue: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP

Input: (gen-lambda-with-sticky-stop nil (progn))

Output:
(defmacro gen-lambda-with-sticky-stop (&rest rest)
  `(make-instance
    'basic-generator
    :function (sticky-stop-lambda ,@rest)))


Instruction:
Generate a defmacro form that transforms code like this:
(special-symbol-reprogv nil
    :key
  nil)

Pattern to recognize: Macro call that should be transformed by SPECIAL-SYMBOL-REPROGV

Input:
(special-symbol-reprogv nil
    :key
  nil)

Output: (defmacro SPECIAL-SYMBOL-REPROGV ...)


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

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

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

Output:
(defmacro multiple-value-prog2 (first-form second-form &body forms)
  "Evaluates FIRST-FORM, then SECOND-FORM, and then FORMS. Yields as its value
   all the value returned by SECOND-FORM."
  `(progn ,first-form (multiple-value-prog1 ,second-form ,@forms)))


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

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

Input: (fsetf nil nil)

Output:
(defmacro fsetf (place value &rest more)
  ;; First we need to find the "container" variable
  (let ((container (find-container place)))
    (with-gensyms (val-sym)
      (if more
          `(let ((,val-sym ,value))
             (setf ,container (modf ,place ,val-sym))
             (fsetf ,@more))
          `(let ((,val-sym ,value))
             (setf ,container (modf ,place ,val-sym))
             ,val-sym)))))


Instruction:
Generate a defmacro form that transforms code like this:
(define-ps-symbol-macro nil nil)

Pattern to recognize: Macro call that should be transformed by DEFINE-PS-SYMBOL-MACRO

Input: (define-ps-symbol-macro nil nil)

Output: (defmacro DEFINE-PS-SYMBOL-MACRO ...)


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

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

Input:
(destructuring-case nil
  (progn))

Output: (defmacro DESTRUCTURING-CASE ...)


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

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

Input: (xhtml)

Output:
(defmacro xhtml (&rest tags)
  `(with-doctype :xhtml
     (tag->string (cons :html ',tags))))


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

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

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

Output: (defmacro LAMBDA* ...)


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

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

Input: (is-expand nil :key nil)

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:
(labels* nil
  :key
  nil)

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

Input:
(labels* nil
  :key
  nil)

Output: (defmacro LABELS* ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(c_?dbg
  nil)

Problem: Macro call that should be transformed by C_?DBG

Input:
(c_?dbg
  nil)

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


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

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

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

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


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

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

Input:
(if-not-let nil
  nil)

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


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

Issue: Macro call that should be transformed by SOME->>

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

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


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

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

Input:
(lambda-bind nil
  :key
  nil)

Output:
(defmacro lambda-bind ((&rest instrs) &body body)
  "Use `bind' to allow restructuring of argument to lambda expressions.

This lets you funcall and destructure simultaneously. For example

    (let ((fn (lambda-bind ((a b) c) (cons a c))))
      (funcall fn '(1 2) 3))
    ;; => (1 . 3)

Via eschulte (see git://gist.github.com/902174.git).
"
  #+(or)
  (declare (indent 1))
  (let* ((evald-instrs instrs)
         (syms (mapcar (lambda (_)
			 (declare (ignore _))
			 (gensym))
		       evald-instrs)))
    `(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))


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

Issue: Macro call that should be transformed by DEFPSMACRO

Input:
(defpsmacro nil
    (progn))

Output: (defmacro DEFPSMACRO ...)


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 ->> (init &body exps) (arrow-macro init exps t))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(fm^v nil)

Problem: Macro call that should be transformed by FM^V

Input: (fm^v nil)

Output:
(defmacro fm^v (id)
  `(value (fm^ ,id)))


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

Problem: Macro call that should be transformed by FAIL

Input: (fail nil nil)

Output:
(defmacro fail (&rest message-args)
  "Simply generate a FAIL."
  `(process-failure ',message-args
                    ,@message-args))


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

Problem: Macro call that should be transformed by LAMBDA-CMATCH1

Input:
(lambda-cmatch1 common-lisp:nil
  :key
  common-lisp:nil)

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


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

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

Input:
(match-of nil
    :key
  nil)

Output:
(defmacro match-of (union expr &body clauses &environment env)
  "Do pattern matching on an algebraic data type.

UNION should be an algebraic data type.

Each clause in CLAUSES has a pattern as its first element.

If the pattern is a symbol, it matches a unit type.

If the pattern is a list, it matches a constructor.

If the pattern is an underscore, it introduces a default or
fallthrough clause.

If the pattern is a list that starts with `or', it is a disjunction of
other patterns."
  (check-match-exhaustive union clauses env)
  `(ematch ,expr
     ,@(loop for (pattern . body) in clauses
             collect `(,(nth-value 1 (pattern-type pattern union))
                       ,@body))))


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

Problem: Macro call that should be transformed by REM-BOPS

Input: (rem-bops nil nil)

Output: (defmacro REM-BOPS ...)


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

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

Input: (defvar* nil (progn))

Output: (defmacro DEFVAR* ...)


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

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

Input: (markup nil nil)

Output:
(defmacro markup (&rest tags)
  `(%write-strings
    ,@(loop for tag in tags
            append (tag->string tag))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(foreign-funcall-pointer-varargs nil :key nil)

Issue: Macro call that should be transformed by FOREIGN-FUNCALL-POINTER-VARARGS

Input: (foreign-funcall-pointer-varargs nil :key nil)

Output:
(defmacro foreign-funcall-pointer-varargs (pointer options fixed-args
                                           &rest varargs)
  "Wrapper around %FOREIGN-FUNCALL-POINTER that translates its
arguments and does type promotion for the variadic arguments."
  (foreign-funcall-varargs-form pointer options fixed-args varargs t))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(special-symbol-progv nil
    nil)

Problem: Macro call that should be transformed by SPECIAL-SYMBOL-PROGV

Input:
(special-symbol-progv nil
    nil)

Output: (defmacro SPECIAL-SYMBOL-PROGV ...)


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

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

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

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

    (as <type> <expr>)

is equivalent to

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

and

    (as <type>)

is equivalent to

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

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

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


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

Problem: Macro call that should be transformed by RIGHT

Input: (right nil nil)

Output:
(defmacro right (parser &rest parsers)
  "Combination of parsers yielding the result of the rightmost one."
  `(*> ,parser ,@parsers))


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

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

Input: (html5 nil (progn))

Output:
(defmacro html5 (&rest tags)
  `(with-doctype :html5
     (tag->string (cons :html ',tags))))


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

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

Input: (make nil)

Output: (defmacro MAKE ...)


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

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

Input:
(with-html
  nil
  nil)

Output:
(defmacro with-html (&body body &environment env)
  "Interpret BODY as HTML. Consult README.txt for the syntax."
  `(let ((*html* (ensure-html-stream *html*)))
     ,(if (and (null (cdr body)) (atom (car body)))
          (car body)
          `(progn ,@(parse-html body env)))))


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

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

Input: (make-list)

Output:
(defmacro make-list (cl:&rest forms)
  "Create a heterogeneous Coalton `List` of objects. This macro is
deprecated; use `coalton/list:make`."
  (cl:labels
      ((list-helper (forms)
         (cl:if (cl:endp forms)
                `coalton:Nil
                `(coalton:Cons ,(cl:car forms) ,(list-helper (cl:cdr forms))))))
    (list-helper forms)))


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

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

Input: (defpackage common-lisp:nil)

Output: (defmacro DEFPACKAGE ...)


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

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

Input:
(sunless nil
  (progn))

Output:
(defmacro sunless (test &body body)
  "Like UNLESS, except binds the test form to IT (via SYMBOL-MACROLET) for the
scope of the body. IT can be set with SETF."
  `(symbolic unless ,test ,@body))


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

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

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

Output: (defmacro DEFINE-METHOD-COMBINATION ...)


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

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

Input:
(ensure-list nil
  (progn))

Output:
(defmacro ensure-list (item &body body)
  `(let ((,item (if (listp ,item) ,item '(,item))))
     ,@body))


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

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

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

Output: (defmacro INITIALLY ...)


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

Problem: Macro call that should be transformed by MAKE*

Input: (make* nil)

Output: (defmacro MAKE* ...)


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

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

Input:
(local*
  nil
  (progn))

Output:
(defmacro local* (&body body)
  "Like `local', but leave the last form in BODY intact.

     (local*
       (defun aux-fn ...)
       (defun entry-point ...))
     =>
     (labels ((aux-fn ...))
       (defun entry-point ...))"
  `(local
     ,@(butlast body)
     (without-internal-definitions ,@(last body))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(eval-and-compile
  nil
  :key
  nil)

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

Input:
(eval-and-compile
  nil
  :key
  nil)

Output:
(defmacro eval-and-compile (&body body)
  "Emacs's `eval-and-compile'.
Alias for `eval-always'."
  `(eval-always
     ,@body))


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

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

Input: (stop-when 'lol-gen::some-name)

Output: (defmacro STOP-WHEN ...)


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

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

Input:
(->>
  nil
  (progn))

Output: (defmacro ->> ...)


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

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

Input: (is nil (progn))

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

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

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

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

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(print-values)

Issue: Macro call that should be transformed by PRINT-VALUES

Input: (print-values)

Output: (defmacro PRINT-VALUES ...)


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

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

Input:
(on nil
    (progn))

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:
You are a Common Lisp macro expert. Given this code pattern:
(defrte nil nil)

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

Input: (defrte nil nil)

Output: (defmacro DEFRTE ...)


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

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

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

Output: (defmacro INLINE ...)


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

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

Input: (lambda ())

Output: (defmacro LAMBDA ...)


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

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

Input: (markup nil (progn))

Output:
(defmacro markup (&rest tags)
  `(%write-strings
    ,@(loop for tag in tags
            append (tag->string tag))))


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

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

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

Output:
(defmacro cond-every (&body clauses)
  "Like `cond', but instead of stopping after the first clause that
succeeds, run all the clauses that succeed.

Return the value of the last successful clause.

If a clause begins with `cl:otherwise', it runs only if no preceding
form has succeeded.

Note that this does *not* do the same thing as a series of `when'
forms: `cond-every' evaluates *all* the tests *before* it evaluates
any of the forms.

From Zetalisp."
  (let* ((otherwise-clause (find 'otherwise clauses :key #'car))
         (test-clauses (remove otherwise-clause clauses))
         (temps (make-gensym-list (length test-clauses))))
    `(let* ,(loop for temp in temps
                  for (test . nil) in test-clauses
                  collect `(,temp ,test))
       ;; Work around Iterate bug. See
       ;; <https://gitlab.common-lisp.net/iterate/iterate/-/issues/11>.
       (if (or ,@temps)
           ,(with-gensyms (ret)
              `(let (,ret)
                 ,@(loop for temp in temps
                         for (nil . body) in test-clauses
                         collect `(when ,temp
                                    (setf ,ret
                                          ,(if (null body)
                                               temp
                                               `(progn ,@body)))))
                 ,ret))
           (progn ,@(rest otherwise-clause))))))


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

Pattern to recognize: Macro call that should be transformed by COLLECT-PLIST

Input: (collect-plist nil (progn))

Output: (defmacro COLLECT-PLIST ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(who-ps-html nil (progn))

What needs to change: Macro call that should be transformed by WHO-PS-HTML

Input: (who-ps-html nil (progn))

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


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

What needs to change: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES

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

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


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

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

Input: (with-inactive-layers 'lol-gen::some-name)

Output: (defmacro WITH-INACTIVE-LAYERS ...)