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

Issue: Macro call that should be transformed by DO-SEQUENCES!

Input: (do-sequences! 'lol-gen::some-name)

Output:
(defmacro do-sequences! (name/seqs &body forms &environment env)
  "Mutable version of DO-SEQUENCES.

   This is the same as DO-SEQUENCES however each NAME, is the name of
   a symbol-macro, that is introduced, which expands to the 'place',
   suitable for use with SETF, of the current sequence element, rather
   than a variable storing its value. This allows the elements of the
   sequence to be mutated.

   NOTE: This macro does not support destructuring of the sequence
   elements."

  (let-if ((name name/seqs)
           (seqs (first forms) name/seqs)
           (forms (rest forms) forms))
      (symbolp name/seqs)

    (let ((safety (cadr (assoc 'safety (declaration-information 'optimize env)))))
      `(,(if (> safety 2)
             'do-sequences!-safe%
             'do-sequences!-fast%)

         ,name
         ,seqs
         ,@forms))))


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

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

Input:
(gatherlet nil
  (progn))

Output: (defmacro GATHERLET ...)


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

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

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

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


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

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

Input: (swhen nil)

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


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

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

Input: (mapping)

Output: (defmacro MAPPING ...)


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

Problem: Macro call that should be transformed by NSPLICE-SEQF

Input: (nsplice-seqf nil :key nil)

Output: (defmacro NSPLICE-SEQF ...)


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

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

Input:
(define-shared-method nil
    :key
  nil)

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


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

Issue: Macro call that should be transformed by MAKE-WINDOW-OR-INSTANCE

Input: (make-window-or-instance 'lol-gen::some-name)

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


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

Issue: Macro call that should be transformed by DEFVARIANT

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

Output: (defmacro DEFVARIANT ...)


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

Problem: Macro call that should be transformed by ASIF

Input: (asif nil :key nil)

Output:
(defmacro asif (test then &optional else)
  "Like IF, except binds the result of the test to IT (via LET) for
the the scope of the then-expression, and the test form to IT (via
SYMBOL-MACROLET) for the scope of the else-expression. Within scope of
the else-expression, IT can be set with SETF."
    `(let ((it ,test))
       (if it
	   ,then
	   (symbolic ignore-first ,test ,else))))


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

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

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

Output: (defmacro EXPORT-ACCESSORS ...)


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

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

Input:
(adowhile nil
  (progn))

Output: (defmacro ADOWHILE ...)


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

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

Input: (is-false nil nil)

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


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

Problem: Macro call that should be transformed by LOCAL

Input:
(local
  nil)

Output: (defmacro LOCAL ...)


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

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

Input:
(with-took-usec nil
  :key
  nil)

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


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

Issue: Macro call that should be transformed by KEEP-BOPS

Input: (keep-bops nil nil)

Output: (defmacro KEEP-BOPS ...)


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

Pattern to recognize: Macro call that should be transformed by RG!

Input: (rg! nil)

Output:
(defmacro rg! (id)
  (if (eq id :coach)
      `(fm-other :coach)
    `(fm-find-registered ,id self)))


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

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

Input: (decase nil)

Output:
(defmacro decase (keyform &body clauses)
  "DECASE is a combination of ECASE 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 ECASE,
   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 'ecase))


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

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

Input:
(eval-always
  'lol-gen::some-name)

Output: (defmacro EVAL-ALWAYS ...)


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

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

Input: (fn nil)

Output: (defmacro FN ...)


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

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

Input: (set-data nil (progn))

Output:
(defmacro set-data (obj (name &rest new-values))
  "Mutate the fields of the ADT value OBJ whose constructor is NAME
and whose updated values are NEW-VALUES based on order. If the symbol
'_' is used as a value, that field is not updated. Trailing '_' may be
omitted."
  (let ((once (gensym "ONCE")))
    `(let ((,once ,obj))
       (psetf
        ,@(loop :for i :from 0
                :for x :in new-values
                :when (not (wild? x))
                  :append (list `(,(field name i) ,once)
                                x))))))


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

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

Input:
(define-declaration nil
    :key
  nil)

Output: (defmacro DEFINE-DECLARATION ...)


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

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

Input: (finish nil (progn))

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


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

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

Input:
(ccase-of nil
    nil)

Output:
(defmacro ccase-of (type keyplace &body body &environment env)
  "Like `ecase-of', but providing a `store-value' restart to correct KEYPLACE and try again."
  (check-exhaustiveness 'case type body env)
  `(ccase ,keyplace ,@body))


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

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

Input:
(defobject nil
    (progn))

Output: (defmacro DEFOBJECT ...)


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

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

Input: (when nil :key nil)

Output: (defmacro WHEN ...)


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

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

Input:
(either
  nil
  (progn))

Output: (defmacro EITHER ...)


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

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

Input: (of-type nil (progn))

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


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

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

Input:
(is-every nil
  (progn))

Output:
(defmacro is-every (predicate &body clauses)
  "The input is either a list of lists, or a list of pairs. Generates (is (,predicate ,expr ,value))
   for each pair of elements or (is (,predicate ,expr ,value) ,@reason) for each list."
  `(progn
     ,@(if (every #'consp clauses)
           (loop for (expected actual . reason) in clauses
                 collect `(is (,predicate ,expected ,actual) ,@reason))
           (progn
             (assert (evenp (list-length clauses)))
             (loop for (expr value) on clauses by #'cddr
                   collect `(is (,predicate ,expr ,value)))))))


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

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

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

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


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

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

Input: (c-in nil)

Output:
(defmacro c-in (value)
  `(make-cell
    :inputp t
    :value-state :valid
    :value ,value))


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

Issue: Macro call that should be transformed by TRUE

Input: (true nil)

Output:
(defmacro true (form &optional description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(true ,form)
                   :value-form ',form
                   :body (lambda () ,form)
                   :expected 'T
                   :comparison 'geq
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))


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

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

Input: (js nil)

Output: (defmacro JS ...)


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

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

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

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


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

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

Input: (finally nil (progn))

Output: (defmacro FINALLY ...)


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

Issue: Macro call that should be transformed by FM?

Input: (fm? nil (progn))

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


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

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

Input:
(dynamic-relet nil
  (progn))

Output: (defmacro DYNAMIC-RELET ...)


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

Issue: Macro call that should be transformed by WITH-TRANSACTION

Input:
(with-transaction nil
  nil)

Output:
(defmacro with-transaction (conn &body body)
  "Start a transaction and commit at the end of this block. If the evaluation `body` is interrupted, the transaction is rolled back automatically."
  (let ((conn-var (gensym "CONN-VAR")))
    `(let ((,conn-var ,conn))
       (if (in-transaction ,conn-var)
           (with-savepoint ,conn-var ,@body)
           (%with-transaction ,conn-var ,@body)))))


Instruction:
Generate a defmacro form that transforms code like this:
(with-unique-js-names)

Pattern to recognize: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES

Input: (with-unique-js-names)

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


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(destructuring-ccase-of nil
    (progn))

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

Input:
(destructuring-ccase-of nil
    (progn))

Output:
(defmacro destructuring-ccase-of (type keyplace &body body)
  "Like `destructuring-case-of', but providing a `store-value' restart
to collect KEYPLACE and try again."
  (expand-destructuring-case-of type keyplace body 'ccase-of))


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

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

Input: (@ nil :key nil)

Output: (defmacro @ ...)


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

Issue: Macro call that should be transformed by DEFMACRO-DRIVER

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

Output: (defmacro DEFMACRO-DRIVER ...)


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

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

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

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


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

Write a macro that addresses: Macro call that should be transformed by W/UNIQS

Input:
(w/uniqs nil
  (progn))

Output: (defmacro W/UNIQS ...)


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

Issue: Macro call that should be transformed by SWHEN

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

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


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

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

Input:
(defun* nil
    nil)

Output: (defmacro DEFUN* ...)


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

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

Input:
(lambda-match
  nil
  (progn))

Output: (defmacro LAMBDA-MATCH ...)


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

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

Input: (ignore common-lisp:nil)

Output: (defmacro IGNORE ...)


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

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

Input: (like nil (progn))

Output:
(defmacro like (got regex &optional desc)
  (with-gensyms (duration result)
    (once-only (regex desc)
      `(with-catching-errors (:description ,desc :expected ,regex)
         (with-duration ((,duration ,result) ,got)
           (test ,result ,regex ,desc
                 :duration ,duration
                 :test-fn (lambda (x y) (not (null (ppcre:scan y x))))
                 :report-expected-label "be like"))))))


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

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

Input:
(defalias nil
  (progn))

Output:
(defmacro defalias (alias &body (def &optional docstring)
                    &environment env)
  "Define a value as a top-level function.

     (defalias string-gensym (compose #'gensym #'string))

Like (setf (fdefinition ALIAS) DEF), but with a place to put
documentation and some niceties to placate the compiler.

Note that a function defined with `defalias' is declared `notinline'.
This is a matter of semantics: before we can assign to the function,
we must make it assignable (which is what `notinline' means).

Name from Emacs Lisp."
  `(progn
     (declaim (notinline ,alias))
     ,(multiple-value-bind (env decls lambda)
          (let-over-lambda def env)
        ;; If we can expand DEF into a lambda (possibly with some
        ;; variable bindings around it) then splice that lambda in
        ;; directly as the body of the function. (This is the same
        ;; function we use to resolve lambdas in `fbind'.)
        (if lambda
            (ematch lambda
              ((list* (and _ (eql 'lambda)) args body)
               `(let ,env
                  (declare ,@decls)
                  (defun ,alias ,args
                    ,@(unsplice docstring)
                    ,@body))))
            (with-unique-names (temp)
              `(let ((,temp (ensure-function ,def)))
                 (declare (type function ,temp))
                 ;; Give the function a temporary definition at
                 ;; compile time so the compiler doesn't complain
                 ;; about its being undefined.
                 (defun ,alias (&rest args)
                   (apply ,temp args))
                 (setf (fdefinition ',alias) ,temp)
                 ,@(unsplice
                    (and docstring
                         `(setf (documentation ',alias 'function) ,docstring)))))))))


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

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

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

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

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

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

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

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

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

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


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

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

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

Output: (defmacro RTE-ECASE ...)


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

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

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

Output: (defmacro DO-COMBINATIONS ...)


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

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

Input: (cond-<>>)

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


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

Issue: Macro call that should be transformed by JOR

Input: (jor nil)

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


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

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

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

Output: (defmacro DOTIMES ...)


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

Problem: Macro call that should be transformed by DEFDATA

Input:
(defdata nil
  :key
  nil)

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

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

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

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

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

Constructors is a list of clauses with the following grammar:

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

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

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

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

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

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

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

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


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

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

Input:
(ensure-list nil
  nil)

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:
(and-bind nil nil)

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

Input: (and-bind nil nil)

Output: (defmacro AND-BIND ...)


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

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

Input: (with-packages-unlocked nil)

Output: (defmacro WITH-PACKAGES-UNLOCKED ...)


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

Issue: Macro call that should be transformed by DEFGENERIC

Input:
(defgeneric nil
    (progn))

Output: (defmacro DEFGENERIC ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-foreign-objects nil
  nil)

Issue: Macro call that should be transformed by WITH-FOREIGN-OBJECTS

Input:
(with-foreign-objects nil
  nil)

Output:
(defmacro with-foreign-objects (bindings &body body)
  (if bindings
      `(with-foreign-object ,(car bindings)
         (with-foreign-objects ,(cdr bindings)
           ,@body))
      `(progn ,@body)))


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

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

Input:
(possibly?
  nil
  (progn))

Output: (defmacro POSSIBLY? ...)


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

Problem: Macro call that should be transformed by SCASE

Input:
(scase nil
  (progn))

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


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

Issue: Macro call that should be transformed by ECASE

Input: (ecase nil (progn))

Output: (defmacro ECASE ...)


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

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

Input: (2nd 'lol-gen::some-name)

Output:
(defmacro 2nd (form)
  "(NTH-VALUE 1 FORM)"
  `(nth-value 1 ,form))


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

Issue: Macro call that should be transformed by ALL-OF

Input: (all-of nil)

Output: (defmacro ALL-OF ...)


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

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

Input: (-> nil)

Output:
(defmacro -> (x &rest forms)
  "Threads the expr through FORMS. Inserts X as the
   second item in the first form, or in place of % if it is present in the form,
   making a list of it if it is not a list already.
   If there are more forms, inserts the first form
   as the second item in second form, etc."
  (if (first forms)
      (let* ((form (first forms))
             (threaded (if (listp form)
                           (if (member '% form)
                               `(funcall (lambda (%) ,form) ,x)
                               `(,(first form) ,x ,@(rest form)))
                           `(,form ,x))))
        `(-> ,threaded ,@(rest forms)))
      x))


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

Problem: Macro call that should be transformed by WHEN-LET

Input: (when-let nil)

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

BINDINGS must be either single binding of the form:

 (variable initial-form)

or a list of bindings of the form:

 ((variable-1 initial-form-1)
  (variable-2 initial-form-2)
  ...
  (variable-n initial-form-n))

All initial-forms are executed sequentially in the specified order. Then all
the variables are bound to the corresponding values.

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


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

Issue: 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:
(pprint-coalton-codegen-ast
  common-lisp:nil
  (common-lisp:progn))

Pattern to recognize: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST

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

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


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

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

Input: (defproto nil :key nil)

Output: (defmacro DEFPROTO ...)


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

Issue: Macro call that should be transformed by LIST-OF

Input:
(list-of nil
  nil)

Output: (defmacro LIST-OF ...)


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

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

Input: (static-let* nil)

Output:
(defmacro static-let* ((&rest bindings) &body body &environment env)
  "Like `let*', except the variables are only initialized once and
retain their values between different invocations of `body'.

Every static binding is similar to a `let' binding, except it can have
additional keyword arguments:

- `type' Denotes the type of the variable.
- `once' If true, then binding initialization and mutation will be
         thread-safe.
- `flush' If true, this binding will be flushable. Defaults to true.
- `in' Denotes the static binding group in which the binding will be
       placed for flushing. Defaults to the value of `*package'.
- `read-only' If true, then the binding cannot be mutated with `setf'.

Static bindings can be flushed via `flush-static-binding-group' and
`flush-all-static-binding-groups'; the latter is automatically pushed
into `uiop:*dump-image-hooks*' by Serapeum.

An unflushable static binding will carry its value over into dumped
Lisp binaries."
  (parse-static-let* bindings body env))


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

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

Input: (maxf nil :key nil)

Output: (defmacro MAXF ...)


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

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

Input: (static-let nil)

Output:
(defmacro static-let ((&rest bindings) &body body)
  "Like `let', except the variables are only initialized once and
retain their values between different invocations of `body'.

Every static binding is similar to a `let' binding, except it can have
additional keyword arguments:

- `type' Denotes the type of the variable.
- `once' If true, then binding initialization and mutation will be
         thread-safe.
- `flush' If true, this binding will be flushable. Defaults to true.
- `in' Denotes the static binding group in which the binding will be
       placed for flushing. Defaults to the value of `*package'.
- `read-only' If true, then the binding cannot be mutated with `setf'.

Static bindings can be flushed via `flush-static-binding-group' and
`flush-all-static-binding-groups'; the latter is automatically pushed
into `uiop:*dump-image-hooks*' by Serapeum.

An unflushable static binding will carry its value over into dumped
Lisp binaries."
  (parse-static-let bindings body))


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

Issue: Macro call that should be transformed by WITH-GENSYMS

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

Output:
(defmacro with-gensyms ((&rest names) &body body)
  "Provide gensyms for given NAMES."
  `(let ,(loop :for n :in names :collect `(,n (gensym)))
     ,@body))


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

Problem: Macro call that should be transformed by WNOTRC

Input:
(wnotrc nil
  nil)

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


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

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

Input: (fgatherlet nil)

Output: (defmacro FGATHERLET ...)


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

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

Input: (define-template nil :key nil)

Output: (defmacro DEFINE-TEMPLATE ...)


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

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

Input:
(defpattern nil
    nil)

Output: (defmacro DEFPATTERN ...)