j14i/cl-macros huggingface dataset:
Create a Common Lisp macro for the following transformation. Before code:
(doseq! (item seq :start start :end end) (setf item value))

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

Macro definition:
(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))))

Macroexpansion:
(do-sequences! nil ((item seq :start start :end end)) (setf item value))
Create a Common Lisp macro for the following transformation. Before code:
(def-neo4j-fun get-path (node-id to-node-id relationships (max-depth 3) (algorithm :shortest-path)) :post (:uri-spec (format nil "node/~A/path" node-id)) (:encode (list (list (cons "to" to-node-id) :node-url) (list (cons "relationships" relationships)) (list (cons "max_depth" max-depth)) (list (cons "algorithm" (case algorithm (:shortest-path "shortestPath") (:all-paths "allPaths") (:all-simple-paths "allSimplePaths") (:dijkstra "dijkstra"))))) :object) (:status-handlers (200 (decode-neo4j-json-output body)) (404 (error 'path-not-found-error :uri uri))))

What needs to change: Macro call that should be transformed by def-neo4j-fun

Macro definition:
(defmacro def-neo4j-fun (name lambda-list method &rest args)
  `(progn
     (defun ,name (&key ,@lambda-list)
       (let ((uri ,(cadr (assoc :uri-spec args)))
             (json (encode-neo4j-json-payload ,@(aif (assoc :encode args)
                                                     (cdr it)
                                                     (list '() :string)))))
         (make-neo4j-request ,method uri json
                             (list ,@(mapcar (lambda (handler)
                                               `(list ,(car handler) (lambda (body uri json)
                                                                  ,(cadr handler))))
                                             (cdr (assoc :status-handlers args)))))))))

Macroexpansion:
(progn (defun get-path (&key node-id to-node-id relationships (max-depth 3) (algorithm :shortest-path)) (let ((uri (format nil "node/~A/path" node-id)) (json (encode-neo4j-json-payload (list (list (cons "to" to-node-id) :node-url) (list (cons "relationships" relationships)) (list (cons "max_depth" max-depth)) (list (cons "algorithm" (case algorithm (:shortest-path "shortestPath") (:all-paths "allPaths") (:all-simple-paths "allSimplePaths") (:dijkstra "dijkstra"))))) :object))) (make-neo4j-request :post uri json (list (list 200 (lambda (body uri json) (decode-neo4j-json-output body))) (list 404 (lambda (body uri json) (error (quote path-not-found-error) :uri uri))))))))
Define a macro that eliminates this repetitive pattern:
(with-decoder-simple-list-semantics (setf x (decode-json-from-string "{\"x\":1}")) (is (equal (symbol-package (caar x)) (find-package :cl-user))))

Issue: Macro call that should be transformed by with-decoder-simple-list-semantics

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

Macroexpansion:
(with-shadowed-custom-vars (set-decoder-simple-list-semantics) (setf x (decode-json-from-string "{\"x\":1}")) (is (equal (symbol-package (caar x)) (find-package :cl-user))))
Generate a defmacro form that transforms code like this:
(define-error invalid-form-list () (code) "Tried to compile form however the first element of the form was a list: ~s" code)

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

Macro definition:
(defmacro define-error (name (&key (error-type 'varjo-error) (prefix "Varjo"))
                            (&rest args) error-string &body body)
  `(defcondition ,name (:error-type ,error-type :prefix ,prefix) ,args
       ,error-string ,@body))

Macroexpansion:
(defcondition invalid-form-list (:error-type varjo-error :prefix "Varjo") (code) "Tried to compile form however the first element of the form was a list: ~s" code)
You are a Common Lisp macro expert. Given this code pattern:
(augment arglist (list 'generate))

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

Macro definition:
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

Macroexpansion:
(setf arglist (nconc arglist (list (quote generate))))
Write a Common Lisp macro to handle this code pattern:
(lambda* nil)

Problem: Macro call that should be transformed by LAMBDA*

Macro definition:
(defmacro LAMBDA* ...)

Macroexpansion:
(lambda () (the t nil))
Define a macro that eliminates this repetitive pattern:
(with-file-name-lock-held () (format nil "~:@(~36,8,'0R~)" (random (expt 36 8) *name-random-state*)))

Issue: Macro call that should be transformed by with-file-name-lock-held

Macro definition:
(defmacro with-file-name-lock-held (() &body body)
  `(bordeaux-threads:with-lock-held (*create-file-name-lock*)
     ,@body))

Macroexpansion:
(bordeaux-threads:with-lock-held (*create-file-name-lock*) (format nil "~:@(~36,8,'0R~)" (random (expt 36 8) *name-random-state*)))
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym finally :finally)

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

Macro definition:
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

Macroexpansion:
(eval-always (setf (get (quote finally) (quote synonym)) (quote :finally)))
Create a Common Lisp macro for the following transformation. Before code:
(defclause symbols-in (package-or-packages &rest symbol-types) "Iterates over the symbols in one or more packages. Symbol-types follows the specification of cl:with-package-iterator." (let ((variables (ensure-list *iteration-variable*)) (package-list (ensure-list package-or-packages)) (symbol-types (or symbol-types '(:external))) (iterator (gensym "PACKAGE-ITERATOR")) (test (gensym "TEST"))) (unless (<= 1 (length variables) 3) (error "Invalid variable specification for package entry, expected (symbol &optional accessibility package) but got ~S" *iteration-variable*)) `(,(make-wrapper :function (lambda (body) `(with-package-iterator (,iterator (list ,@package-list) ,@symbol-types) ,body))) ,(make-iteration :bindings `(,test ,@variables) :initializations `((setf (values ,test ,@variables) (,iterator))) :steps `((setf (values ,test ,@variables) (,iterator))) :postconditions `((not (null ,test)))))))

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

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

Macroexpansion:
(progn (defmacro symbols-in (package-or-packages &rest symbol-types) "Iterates over the symbols in one or more packages. Symbol-types follows the specification of cl:with-package-iterator." (let ((variables (ensure-list *iteration-variable*)) (package-list (ensure-list package-or-packages)) (symbol-types (or symbol-types (quote (:external)))) (iterator (gensym "PACKAGE-ITERATOR")) (test (gensym "TEST"))) (unless (<= 1 (length variables) 3) (error "Invalid variable specification for package entry, expected (symbol &optional accessibility package) but got ~S" *iteration-variable*)) (sb-int:quasiquote (#S(sb-impl::comma :expr (make-wrapper :function (lambda (body) (sb-int:quasiquote (with-package-iterator (#S(sb-impl::comma :expr iterator :kind 0) (list #S(sb-impl::comma :expr package-list :kind 2)) #S(sb-impl::comma :expr symbol-types :kind 2)) #S(sb-impl::comma :expr body :kind 0))))) :kind 0) #S(sb-impl::comma :expr (make-iteration :bindings (sb-int:quasiquote (#S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr variables :kind 2))) :initializations (sb-int:quasiquote ((setf (values #S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr variables :kind 2)) (#S(sb-impl::comma :expr iterator :kind 0))))) :steps (sb-int:quasiquote ((setf (values #S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr variables :kind 2)) (#S(sb-impl::comma :expr iterator :kind 0))))) :postconditions (sb-int:quasiquote ((not (null #S(sb-impl::comma :expr test :kind 0)))))) :kind 0))))) (pushnew (quote symbols-in) *clauses*))
Create a Common Lisp macro for the following transformation. Before code:
(collect-nth nil (progn))

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

Macro definition:
(defmacro COLLECT-NTH ...)

Macroexpansion:
(common-lisp:let* ((#:generator-409 (generator (progn)))
                   #:items-401
                   (#:counter-403 nil)
                   (#:item-404 nil))
  (declare (type generator #:generator-409)
           (type (null-or fixnum) #:counter-403)
           (type (null-or t) #:item-404))
  (tagbody
   #:ll-410
    (setq #:items-401 (next-in #:generator-409 (go end)))
    (when (zerop #:counter-403) (setq #:item-404 #:items-401) (go end))
    (decf #:counter-403)
    (go #:ll-410)
   end)
  #:item-404)
You are a Common Lisp macro expert. Given this code pattern:
(with-yield-binds (format nil "ALTER COLUMN ~A~:[~; TYPE ~:*~A~]~:[~; SET DEFAULT ~:*~A~]~:[~; DROP DEFAULT~]~A" (yield (alter-column-clause-column-name clause)) (and (alter-column-clause-type clause) (let ((*use-placeholder* nil)) (yield (alter-column-clause-type clause)))) (and (alter-column-clause-set-default clause) (yield (alter-column-clause-set-default clause))) (alter-column-clause-drop-default clause) (cond ((eq (alter-column-clause-not-null clause) :unspecified) "") ((alter-column-clause-not-null clause) " SET NOT NULL") (T " DROP NOT NULL"))))

Write a macro that addresses: Macro call that should be transformed by with-yield-binds

Macro definition:
(defmacro with-yield-binds (&body body)
  `(let ((*bind-values* nil)
         (*use-global-bind-values* t))
     (values
      (progn ,@body)
      (loop for bind in (reverse *bind-values*)
            append bind))))

Macroexpansion:
(let ((*bind-values* nil) (*use-global-bind-values* t)) (values (progn (format nil "ALTER COLUMN ~A~:[~; TYPE ~:*~A~]~:[~; SET DEFAULT ~:*~A~]~:[~; DROP DEFAULT~]~A" (yield (alter-column-clause-column-name clause)) (and (alter-column-clause-type clause) (let ((*use-placeholder* nil)) (yield (alter-column-clause-type clause)))) (and (alter-column-clause-set-default clause) (yield (alter-column-clause-set-default clause))) (alter-column-clause-drop-default clause) (cond ((eq (alter-column-clause-not-null clause) :unspecified) "") ((alter-column-clause-not-null clause) " SET NOT NULL") (t " DROP NOT NULL")))) (loop for bind in (reverse *bind-values*) append bind)))
You are a Common Lisp macro expert. Given this code pattern:
(do+ outer-loop (do+ inner-loop (do+ (terminate outer-loop 3))))

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

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

Macroexpansion:
(do+/internal nil outer-loop (do+ inner-loop (do+ (terminate outer-loop 3))))
You are a Common Lisp macro expert. Given this code pattern:
(with-color (:cyan :stream stream) (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream))

Write a macro that addresses: Macro call that should be transformed by with-color

Macro definition:
(defmacro with-color ((color &rest args) &body body)
  (cond
    ((or (eq color :gray)
         (eq color :grey))
     `(if *enable-colors*
          (with-gray ,(or (getf args :stream) t) ,@body)
          (progn ,@body)))
    (T `(if *enable-colors*
            (if (or (eq ,color :gray)
                    (eq ,color :grey)
                    (eq ,color cl-colors:+gray+)
                    (eq ,color cl-colors:+grey+))
                (with-gray ,(or (getf args :stream) t) ,@body)
                (cl-ansi-text:with-color (,color ,@args) ,@body))
            (progn ,@body)))))

Macroexpansion:
(if *enable-colors* (if (or (eq :cyan :gray) (eq :cyan :grey) (eq :cyan +gray+) (eq :cyan +grey+)) (with-gray stream (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream)) (cl-ansi-text:with-color (:cyan :stream stream) (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream))) (progn (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream)))
You are a Common Lisp macro expert. Given this code pattern:
($send nil (progn))

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

Macro definition:
(defmacro $SEND ...)

Macroexpansion:
(send-message nil (progn))
You are a Common Lisp macro expert. Given this code pattern:
(define-shell-component myth :input-type "myth" :output-type "css" :shell-command "myth")

Write a macro that addresses: Macro call that should be transformed by define-shell-component

Macro definition:
(defmacro define-shell-component (name &key input-type output-type shell-command)
  "Define an ASDF component that's compiled by running a shell command."
  `(define-component ,name
     :input-type ,input-type
     :output-type ,output-type
     :compile-function (lambda (input-pathname output-pathname)
                         (inferior-shell:run (list ,@(ensure-list shell-command)
                                                    input-pathname
                                                    output-pathname)
                                             :show t))))

Macroexpansion:
(define-component myth :input-type "myth" :output-type "css" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "myth" input-pathname output-pathname) :show t)))
Create a Common Lisp macro for the following transformation. Before code:
(define-global-var nil nil)

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

Macro definition:
(defmacro DEFINE-GLOBAL-VAR ...)

Macroexpansion:
(sb-ext:defglobal nil nil)
Write a Common Lisp macro to handle this code pattern:
(with-html-string (:x-y "Hello"))

Problem: Macro call that should be transformed by with-html

Macro definition:
(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)))))

Macroexpansion:
(with-output-to-string (*html*) (with-html (:x-y "Hello")))
Create a Common Lisp macro for the following transformation. Before code:
(reduced-typecase 'some-name)

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

Macro definition:
(defmacro REDUCED-TYPECASE ...)

Macroexpansion:
(typecase 'some-name)
You are a Common Lisp macro expert. Given this code pattern:
(c?-with-stored (v :foo store 'nothing) (bwhen (val (value v)) (1+ val)))

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

Macro definition:
(defmacro c? (&body body)
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :rule (c-lambda ,@body)))

Macroexpansion:
(c? (bwhen-c-stored (v :foo store (quote nothing)) (bwhen (val (value v)) (1+ val))))
Generate a defmacro form that transforms code like this:
(define-final-class nil :key nil)

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

Macro definition:
(defmacro DEFINE-FINAL-CLASS ...)

Macroexpansion:
(defclass nil :key nil (:metaclass final-class))
Create a Common Lisp macro for the following transformation. Before code:
(assoc-cdr :authorization--endpoint disc)

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

Macro definition:
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

Macroexpansion:
(cdr (assoc :authorization--endpoint disc :test (function eql)))
Write a Common Lisp macro to handle this code pattern:
(-> :p (a) (declare (type fixnum a)) (the fixnum (1+ a)))

Problem: Macro call that should be transformed by ->

Macro definition:
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

Macroexpansion:
(atomically :p (a) (declare (type fixnum a)) (the fixnum (1+ a)))
Create a Common Lisp macro for the following transformation. Before code:
(with-yield)

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

Macro definition:
(defmacro WITH-YIELD ...)

Macroexpansion:
(isolate-cont
  (enable-yield
    nil))
You are a Common Lisp macro expert. Given this code pattern:
(defclause initially (&rest forms) "Evaluates <form> before the first iteration." (mapcar (lambda (form) (make-initialization :form form)) forms))

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

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

Macroexpansion:
(progn (defmacro initially (&rest forms) "Evaluates <form> before the first iteration." (mapcar (lambda (form) (make-initialization :form form)) forms)) (pushnew (quote initially) *clauses*))
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 -<>

Macro definition:
(defmacro -<> ...)

Macroexpansion:
(let* ((#:var204 nil) (#:var205 (nil #:var204)))
  #:var205)
Generate a defmacro form that transforms code like this:
(cond->> 'some-name)

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

Macro definition:
(defmacro COND->> ...)

Macroexpansion:
(let* ((#:|cond139| 'some-name))
  #:|cond139|)
Define a macro that eliminates this repetitive pattern:
(defvariant nil
  nil)

Issue: Macro call that should be transformed by DEFVARIANT

Macro definition:
(defmacro DEFVARIANT ...)

Macroexpansion:
(progn
 (defstruct (nil (:constructor nil)))
 (defstruct (nil-nil (:include nil)))
 (defmacro match-nil (expr &body match-cases)
   #A((34) base-char . "Match values of variant type: NIL.")
   (let ((expr-var (gensym "-val")))
     `(let ((,expr-var ,expr))
        ,(build-dispatch `,'nil `,'(nil) match-cases expr-var)))))
Generate a defmacro form that transforms code like this:
(with-indentation (with-xml-group-element (s "tspan" opts) (string->xml s text)))

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

Macro definition:
(defmacro with-indentation (&body body)
  `(let ((*indent-level* (+ *indent-level* *indent-spacing*)))
     ,@body))

Macroexpansion:
(let ((*indent-level* (+ *indent-level* *indent-spacing*))) (with-xml-group-element (s "tspan" opts) (string->xml s text)))
Define a macro that eliminates this repetitive pattern:
(builder (:backtrace :output *test-error-output* :result-on-error '(500 (:content-type "text/plain") ("Internal Server Error"))) (lambda (env) (declare (ignore env)) (error "Error occured")))

Issue: Macro call that should be transformed by builder

Macro definition:
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

Macroexpansion:
(reduce (function funcall) (remove-if (function null) (list (lambda (#:app196) (funcall (find-middleware :backtrace) #:app196 :output *test-error-output* :result-on-error (quote (500 (:content-type "text/plain") ("Internal Server Error"))))))) :initial-value (to-app (lambda (env) (declare (ignore env)) (error "Error occured"))) :from-end t)
Generate a defmacro form that transforms code like this:
(draw group (:line :x1 x :y1 y :x2 dx :y2 dy))

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

Macro definition:
(defmacro draw (scene (shape &rest params) &rest opts)
  (let ((element (gensym)))
    `(let ((,element (funcall #'make-svg-element ,shape (append (list ,@params) (list ,@opts)))))
       (add-element ,scene ,element)
       ,element)))

Macroexpansion:
(let ((#:g158 (funcall (function make-svg-element) :line (append (list :x1 x :y1 y :x2 dx :y2 dy) (list))))) (add-element group #:g158) #:g158)
Write a Common Lisp macro to handle this code pattern:
(-> :one () (increment))

Problem: Macro call that should be transformed by ->

Macro definition:
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

Macroexpansion:
(atomically :one nil (increment))
Define a macro that eliminates this repetitive pattern:
(ps-html nil)

Issue: Macro call that should be transformed by PS-HTML

Macro definition:
(defmacro PS-HTML ...)

Macroexpansion:
(stringify nil)
Define a macro that eliminates this repetitive pattern:
(with-slots nil
    (progn))

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

Macro definition:
(defmacro WITH-SLOTS ...)

Macroexpansion:
(let ((#:g179 (progn)))
  (declare (ignorable #:g179))
  (symbol-macrolet ()))
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym :finding :find)

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

Macro definition:
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

Macroexpansion:
(eval-always (setf (get (quote :finding) (quote synonym)) (quote :find)))
Generate a defmacro form that transforms code like this:
(deferror "22012" db-division-by-zero data-exception)

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

Macro definition:
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

Macroexpansion:
(progn (define-condition db-division-by-zero (data-exception) nil) (setf (gethash "22012" *error-table*) (quote db-division-by-zero)))