Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code:   DatasetGenerationError
Exception:    CastError
Message:      Couldn't cast
messages: list<item: struct<role: string, content: string>>
  child 0, item: struct<role: string, content: string>
      child 0, role: string
      child 1, content: string
category: string
output: string
complexity: string
macroexpand: string
technique: string
input: string
quality_score: double
instruction: string
to
{'instruction': Value('string'), 'input': Value('string'), 'output': Value('string'), 'macroexpand': Value('string'), 'category': Value('string'), 'technique': Value('string'), 'complexity': Value('string'), 'quality_score': Value('float64')}
because column names don't match
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1779, in _prepare_split_single
                  for key, table in generator:
                                    ^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/packaged_modules/json/json.py", line 299, in _generate_tables
                  self._cast_table(pa_table, json_field_paths=json_field_paths),
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/packaged_modules/json/json.py", line 128, in _cast_table
                  pa_table = table_cast(pa_table, self.info.features.arrow_schema)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2321, in table_cast
                  return cast_table_to_schema(table, schema)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2249, in cast_table_to_schema
                  raise CastError(
              datasets.table.CastError: Couldn't cast
              messages: list<item: struct<role: string, content: string>>
                child 0, item: struct<role: string, content: string>
                    child 0, role: string
                    child 1, content: string
              category: string
              output: string
              complexity: string
              macroexpand: string
              technique: string
              input: string
              quality_score: double
              instruction: string
              to
              {'instruction': Value('string'), 'input': Value('string'), 'output': Value('string'), 'macroexpand': Value('string'), 'category': Value('string'), 'technique': Value('string'), 'complexity': Value('string'), 'quality_score': Value('float64')}
              because column names don't match
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1347, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 980, in convert_to_parquet
                  builder.download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 882, in download_and_prepare
                  self._download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 943, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1646, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1832, in _prepare_split_single
                  raise DatasetGenerationError("An error occurred while generating the dataset") from e
              datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

instruction
string
input
string
output
string
macroexpand
string
category
string
technique
string
complexity
string
quality_score
float64
Generate a defmacro form that transforms code like this: (make-name-transformer name "-ZORK") Pattern to recognize: Macro call that should be transformed by make-name-transformer
(make-name-transformer name "-ZORK")
(defmacro make-name-transformer (&rest elements) "Return an accessor name transformer. The unquoted `name' symbol argument is substituted for the slot name. Class option examples: :accessor-name-transformer (make-name-transformer \"FOO-\" name \"-BAR\") Use the slot name directly: :accessor-name-transformer (m...
(lambda (name definition) (declare (ignorable definition)) (concatenate-symbol name "-ZORK"))
control-flow
recursive-expansion
advanced
0.9125
Define a macro that eliminates this repetitive pattern: (check-cursor-attached cluffer:beginning-of-line-p (cursor)) Issue: Macro call that should be transformed by check-cursor-attached
(check-cursor-attached cluffer:beginning-of-line-p (cursor))
(defmacro check-cursor-attached (name arguments) (let ((args (substitute '(cursor cluffer:cursor) 'cursor arguments))) `(defmethod ,name :before ,args (declare (ignore ,@(set-difference (remove 'cursor arguments) lambda-list-keywords))) (unless (cluffer:curs...
(defmethod cluffer:beginning-of-line-p :before ((cursor cluffer:cursor)) (declare (ignore)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (letrec-syntax common-lisp:nil (common-lisp:progn)) Write a macro that addresses: Macro call that should be transformed by LETREC-SYNTAX
(letrec-syntax common-lisp:nil (common-lisp:progn))
(defmacro LETREC-SYNTAX ...)
(common-lisp:macrolet () (common-lisp:progn))
control-flow
basic
0.805
You are a Common Lisp macro expert. Given this code pattern: (augment init-code `((setq ,extra-save-var ,(save-info-iv-ref s-i)))) Write a macro that addresses: Macro call that should be transformed by augment
(augment init-code `((setq ,extra-save-var ,(save-info-iv-ref s-i))))
(defmacro augment (var stuff) `(setf ,var (nconc ,var ,stuff)))
(setf init-code (nconc init-code (sb-int:quasiquote ((setq #S(sb-impl::comma :expr extra-save-var :kind 0) #S(sb-impl::comma :expr (save-info-iv-ref s-i) :kind 0))))))
control-flow
basic
0.805
Generate a defmacro form that transforms code like this: (with-quote-char (map nil (lambda (ex) (format out "~&~A;~%~A" (sxql:yield ex) statement-separator)) expressions)) Pattern to recognize: Macro call that should be transformed by with-quote-char
(with-quote-char (map nil (lambda (ex) (format out "~&~A;~%~A" (sxql:yield ex) statement-separator)) expressions))
(defmacro with-quote-char (&body body) `(let ((sxql:*quote-character* (or sxql:*quote-character* (connection-quote-character *connection*)))) ,@body))
(let ((sxql/sql-type:*quote-character* (or sxql/sql-type:*quote-character* (connection-quote-character *connection*)))) (map nil (lambda (ex) (format out "~&~A;~%~A" (sxql/sql-type:yield ex) statement-separator)) expressions))
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (count-of nil :key nil) Write a macro that addresses: Macro call that should be transformed by COUNT-OF
(count-of nil :key nil)
(defmacro COUNT-OF ...)
(lc (nil :key nil) count)
control-flow
basic
0.7525
Create a Common Lisp macro for the following transformation. Before code: (define-custom-var (:array-scope *array-scope-variables*) '(*internal-decoder*) "A list of symbols naming dynamic variables which should be re-bound in the scope of every JSON Array.") What needs to change: Macro call that should be transformed ...
(define-custom-var (:array-scope *array-scope-variables*) '(*internal-decoder*) "A list of symbols naming dynamic variables which should be re-bound in the scope of every JSON Array.")
(defmacro define-custom-var ((key name) &rest other-args) `(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew '(,name . ,key) *custom-vars* :test #'equal) (defvar ,name ,@other-args))))
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew (quote (*array-scope-variables* . :array-scope)) *custom-vars* :test (function equal)) (defvar *array-scope-variables* (quote (*internal-decoder*)) "A list of symbols naming dynamic variables which should be re-bound in the scope of every JSON Array...
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (with-collectors nil nil) Write a macro that addresses: Macro call that should be transformed by WITH-COLLECTORS
(with-collectors nil nil)
(defmacro WITH-COLLECTORS ...)
(progn nil)
control-flow
basic
0.7525
Define a macro that eliminates this repetitive pattern: (lambda-match0 ((cons key pattern) `(assoc ,key ,pattern))) Issue: Macro call that should be transformed by lambda-match0
(lambda-match0 ((cons key pattern) `(assoc ,key ,pattern)))
(defmacro lambda-match0 (&body clauses) (alexandria:with-gensyms (arg) `(lambda (,arg) (match0 ,arg ,@clauses))))
(lambda (#:arg165) (match0 #:arg165 ((cons key pattern) (sb-int:quasiquote (assoc #S(sb-impl::comma :expr key :kind 0) #S(sb-impl::comma :expr pattern :kind 0))))))
capture-management
gensym
intermediate
0.9125
Create a Common Lisp macro for the following transformation. Before code: (defmacro-driver 'some-name) What needs to change: Macro call that should be transformed by DEFMACRO-DRIVER
(defmacro-driver 'some-name)
(defmacro DEFMACRO-DRIVER ...)
(eval-when (:compile-toplevel :load-toplevel :execute) (defmacro clause-quote-2 (&key ((:quote some-name)) generate)) (iterate::install-clause-info '(quote) '(quote) 'clause-quote-2 nil t) ''some-name)
control-flow
basic
0.7525
Create a Common Lisp macro for the following transformation. Before code: (check-cursor-attached cluffer:items (cursor &key start end)) What needs to change: Macro call that should be transformed by check-cursor-attached
(check-cursor-attached cluffer:items (cursor &key start end))
(defmacro check-cursor-attached (name arguments) (let ((args (substitute '(cursor cluffer:cursor) 'cursor arguments))) `(defmethod ,name :before ,args (declare (ignore ,@(set-difference (remove 'cursor arguments) lambda-list-keywords))) (unless (cluffer:curs...
(defmethod cluffer:items :before ((cursor cluffer:cursor) &key start end) (declare (ignore end start)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (none-of nil :key nil) Write a macro that addresses: Macro call that should be transformed by NONE-OF
(none-of nil :key nil)
(defmacro NONE-OF ...)
(lc (nil :key nil) never)
control-flow
basic
0.7525
Define a macro that eliminates this repetitive pattern: (collect-max nil :key nil) Issue: Macro call that should be transformed by COLLECT-MAX
(collect-max nil :key nil)
(defmacro COLLECT-MAX ...)
(common-lisp:let* ((#:generator-379 (generator :key)) #:items-369 (#:generator-377 (generator nil)) #:numbers-368 (#:number-371 nil) #:result-372) (declare (type generator #:generator-379) (type generator #:gener...
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (is-false t) Pattern to recognize: Macro call that should be transformed by is
(is-false t)
(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 ch...
(let ((#:value201 t)) (if #:value201 (process-failure (quote t) "~S returned the value ~S, which is true" (quote t) #:value201) (add-result (quote test-passed) :test-expr (quote t))))
capture-management
gensym
advanced
0.8725
Create a Common Lisp macro for the following transformation. Before code: (define-shell-component roy :input-type "roy" :output-type "js" :shell-command ("roy" "-r")) What needs to change: Macro call that should be transformed by define-shell-component
(define-shell-component roy :input-type "roy" :output-type "js" :shell-command ("roy" "-r"))
(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) ...
(define-component roy :input-type "roy" :output-type "js" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "roy" "-r" input-pathname output-pathname) :show t)))
control-flow
intermediate
0.9125
Write a Common Lisp macro to handle this code pattern: (define-modf-rewrite cddr (expr) `(cdr (cdr ,(second expr)))) Problem: Macro call that should be transformed by define-modf-rewrite
(define-modf-rewrite cddr (expr) `(cdr (cdr ,(second expr))))
(defmacro define-modf-rewrite (name (expr) &body body) "Define a new rewrite rule. If a form starting with NAME is encountered, call the defined function to return a form that we can deal with (i.e. one defined via DEFINE-MODF-EXPANDER, DEFINE-MODF-FUNCTION, and DEFINE-MODF-METHOD)." `(eval-when (:compile-toplevel...
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cddr) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (cdr (cdr #S(sb-impl::comma :expr (second expr) :kind 0)))))))
control-flow
intermediate
0.9125
Create a Common Lisp macro for the following transformation. Before code: (define-modf-rewrite cdaaar (expr) `(cdr (caaar ,(second expr)))) What needs to change: Macro call that should be transformed by define-modf-rewrite
(define-modf-rewrite cdaaar (expr) `(cdr (caaar ,(second expr))))
(defmacro define-modf-rewrite (name (expr) &body body) "Define a new rewrite rule. If a form starting with NAME is encountered, call the defined function to return a form that we can deal with (i.e. one defined via DEFINE-MODF-EXPANDER, DEFINE-MODF-FUNCTION, and DEFINE-MODF-METHOD)." `(eval-when (:compile-toplevel...
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cdaaar) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (cdr (caaar #S(sb-impl::comma :expr (second expr) :kind 0)))))))
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (when ret-body (setf body (rest ret-body)) (setf type (first ret-body))) Write a macro that addresses: Macro call that should be transformed by when
(when ret-body (setf body (rest ret-body)) (setf type (first ret-body)))
(defmacro when (test &body forms) `(if ,test ,(cl:if (cadr forms) `(progn ,@forms) (car forms))))
(if ret-body (progn (setf body (rest ret-body)) (setf type (first ret-body))))
control-flow
intermediate
0.9125
Create a Common Lisp macro for the following transformation. Before code: (defun/1 getc (fd) (fgetc fd)) What needs to change: Macro call that should be transformed by defun/1
(defun/1 getc (fd) (fgetc fd))
(defmacro defun/1 (name arglist &body body) "Lisp-1 defun; makes function pointers work." `(progn (defun ,name ,arglist (declare (optimize (speed 0) (debug 3) ;; FIXME: Why do minor warnings result in load errors? #+sbcl (sb-ext:inhibit-warnings 3))) ...
(progn (defun getc (fd) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (fgetc fd)) (defparameter getc (vacietis.c:mkptr& (symbol-function (quote getc)))))
control-flow
intermediate
0.86
Write a Common Lisp macro to handle this code pattern: (define-error unable-to-resolve-func-type () (func-name args) "Unable to resolve the result type of function '~a' when called~%with the argument types:~%~a~%" func-name (mapcar #'type->type-spec (mapcar #'primary-type args))) Problem: Macro call that should be tra...
(define-error unable-to-resolve-func-type () (func-name args) "Unable to resolve the result type of function '~a' when called~%with the argument types:~%~a~%" func-name (mapcar #'type->type-spec (mapcar #'primary-type args)))
(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))
(defcondition unable-to-resolve-func-type (:error-type varjo-error :prefix "Varjo") (func-name args) "Unable to resolve the result type of function '~a' when called~%with the argument types:~%~a~%" func-name (mapcar (function type->type-spec) (mapcar (function primary-type) args)))
control-flow
intermediate
0.9125
Write a Common Lisp macro to handle this code pattern: (def-dynenv-macro nil (progn)) Problem: Macro call that should be transformed by DEF-DYNENV-MACRO
(def-dynenv-macro nil (progn))
(defmacro DEF-DYNENV-MACRO ...)
(defmacro nil (progn &environment #:env175) (with-dynenv #:env175))
control-flow
basic
0.7675
Write a Common Lisp macro to handle this code pattern: (define-shell-component sass-strict :input-type "sass" :output-type "css" :shell-command "sass") Problem: Macro call that should be transformed by define-shell-component
(define-shell-component sass-strict :input-type "sass" :output-type "css" :shell-command "sass")
(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) ...
(define-component sass-strict :input-type "sass" :output-type "css" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "sass" input-pathname output-pathname) :show t)))
control-flow
intermediate
0.9125
Generate a defmacro form that transforms code like this: (do+ (accumulating-to foo) (stop-when (> (length foo) 10)) (returning foo) (do+ (for x (in '(1 2 3))) (do+ (for y (in '(a b))) (collect (list x y) :into foo)))) Pattern to recognize: Macro call that should be transformed by do+
(do+ (accumulating-to foo) (stop-when (> (length foo) 10)) (returning foo) (do+ (for x (in '(1 2 3))) (do+ (for y (in '(a b))) (collect (list x y) :into foo))))
(defmacro do+ (&body body) "High-level, extensible iteration construct. Refer to the manual for syntax and semantics." `(do+/internal nil ,@body))
(do+/internal nil (accumulating-to foo) (stop-when (> (length foo) 10)) (returning foo) (do+ (for x (in (quote (1 2 3)))) (do+ (for y (in (quote (a b)))) (collect (list x y) :into foo))))
anaphoric
anaphor,recursive-expansion
basic
0.9
Write a Common Lisp macro to handle this code pattern: (disable-quasiquote-2.0) Problem: Macro call that should be transformed by DISABLE-QUASIQUOTE-2.0
(disable-quasiquote-2.0)
(defmacro DISABLE-QUASIQUOTE-2.0 ...)
(eval-when (:compile-toplevel :load-toplevel :execute) (%disable-quasiquote-2.0))
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (ematch0 args (nil nil) ((list* '&key rest) (list* '&key (process-keyword-args rest))) ((list* '&rest rest) (list* '&rest (process-rest-args rest))) ((list* '&aux rest) args) ((list* (list name) rest) (list* (list name ''_) (process-optional-args rest))) ((list* ...
(ematch0 args (nil nil) ((list* '&key rest) (list* '&key (process-keyword-args rest))) ((list* '&rest rest) (list* '&rest (process-rest-args rest))) ((list* '&aux rest) args) ((list* (list name) rest) (list* (list name ''_) (process-optional-args rest))) ((list* (list name default) rest) (list* (list name default) (pro...
(defmacro ematch0 (what &body clauses) `(match0 ,what ,@clauses (_ (error "level0 match error!"))))
(match0 args (nil nil) ((list* (quote &key) rest) (list* (quote &key) (process-keyword-args rest))) ((list* (quote &rest) rest) (list* (quote &rest) (process-rest-args rest))) ((list* (quote &aux) rest) args) ((list* (list name) rest) (list* (list name (quote (quote _))) (process-optional-args rest))) ((list* (list nam...
control-flow
intermediate
0.9125
Define a macro that eliminates this repetitive pattern: (slet 42 (alet 43 (slet it it))) Issue: Macro call that should be transformed by slet
(slet 42 (alet 43 (slet it it)))
(defmacro slet (form &body body) "Binds the FORM to IT (via SYMBOL-MACROLET) in the scope of the BODY. IT can be set with SETF." `(symbolic ignore-first ,form (progn ,@body)))
(symbolic ignore-first 42 (progn (alet 43 (slet it it))))
control-flow
intermediate
0.875
Write a Common Lisp macro to handle this code pattern: (define-alias-binding sum summing) Problem: Macro call that should be transformed by define-alias-binding
(define-alias-binding sum summing)
(defmacro define-alias-binding (name referenced-binding-name) `(progn (setf (binding ',name) ',referenced-binding-name) ',name))
(progn (setf (binding (quote sum)) (quote summing)) (quote sum))
control-flow
basic
0.8375
Write a Common Lisp macro to handle this code pattern: (define-error flow-ids-mandatory (:error-type varjo-critical-error) (for primary-type) "~a must be given flow id/s when created: type - ~s" for primary-type) Problem: Macro call that should be transformed by define-error
(define-error flow-ids-mandatory (:error-type varjo-critical-error) (for primary-type) "~a must be given flow id/s when created: type - ~s" for primary-type)
(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))
(defcondition flow-ids-mandatory (:error-type varjo-critical-error :prefix "Varjo") (for primary-type) "~a must be given flow id/s when created: type - ~s" for primary-type)
control-flow
intermediate
0.9125
Create a Common Lisp macro for the following transformation. Before code: (defun-compile-time magic-continuation-argument (continuation) (if (or (eq (first (second (second continuation))) '&optional) (eq (first (second (second continuation))) '&rest)) (second (second (second continuation))) (first (second (second conti...
(defun-compile-time magic-continuation-argument (continuation) (if (or (eq (first (second (second continuation))) '&optional) (eq (first (second (second continuation))) '&rest)) (second (second (second continuation))) (first (second (second continuation)))))
(defmacro defun-compile-time (function-name lambda-list &body body) `(eval-when (:compile-toplevel :load-toplevel :execute) (cl:defun ,function-name ,lambda-list ,@body) (eval-when (:compile-toplevel) (compile ',function-name))))
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun magic-continuation-argument (continuation) (if (or (eq (first (second (second continuation))) (quote &optional)) (eq (first (second (second continuation))) (quote &rest))) (second (second (second continuation))) (first (second (second continuatio...
control-flow
intermediate
0.9125
Define a macro that eliminates this repetitive pattern: (product-of 'some-name) Issue: Macro call that should be transformed by PRODUCT-OF
(product-of 'some-name)
(defmacro PRODUCT-OF ...)
(lc ('some-name) multiply)
control-flow
basic
0.7525
You are a Common Lisp macro expert. Given this code pattern: (peek-char*) Write a macro that addresses: Macro call that should be transformed by peek-char*
(peek-char*)
(defmacro peek-char* () "Convenience macro because we always peek at the same string with the same arguments." `(peek-char nil *stream* t nil t))
(peek-char nil *stream* t nil t)
control-flow
intermediate
0.86
Write a Common Lisp macro to handle this code pattern: (do+ (for s (symbols-in :doplus-tests :internal)) (for l (maximizing (length (symbol-name s)) :saving s :in symbol-with-longest-name)) (returning symbol-with-longest-name)) Problem: Macro call that should be transformed by do+
(do+ (for s (symbols-in :doplus-tests :internal)) (for l (maximizing (length (symbol-name s)) :saving s :in symbol-with-longest-name)) (returning symbol-with-longest-name))
(defmacro do+ (&body body) "High-level, extensible iteration construct. Refer to the manual for syntax and semantics." `(do+/internal nil ,@body))
(do+/internal nil (for s (symbols-in :doplus-tests :internal)) (for l (maximizing (length (symbol-name s)) :saving s :in symbol-with-longest-name)) (returning symbol-with-longest-name))
anaphoric
anaphor,recursive-expansion
basic
0.9
You are a Common Lisp macro expert. Given this code pattern: (ematch0 pattern ((list 'guard1 sym test) (pushnew (first (ensure-list sym)) syms)) ((list* 'guard1 sym test more-patterns) (pushnew (first (ensure-list sym)) syms) (analyze-more-patterns more-patterns)) ((list* 'or1 or-subpatterns) (map nil #'analyze-pattern...
(ematch0 pattern ((list 'guard1 sym test) (pushnew (first (ensure-list sym)) syms)) ((list* 'guard1 sym test more-patterns) (pushnew (first (ensure-list sym)) syms) (analyze-more-patterns more-patterns)) ((list* 'or1 or-subpatterns) (map nil #'analyze-pattern or-subpatterns)))
(defmacro ematch0 (what &body clauses) `(match0 ,what ,@clauses (_ (error "level0 match error!"))))
(match0 pattern ((list (quote guard1) sym test) (pushnew (first (ensure-list sym)) syms)) ((list* (quote guard1) sym test more-patterns) (pushnew (first (ensure-list sym)) syms) (analyze-more-patterns more-patterns)) ((list* (quote or1) or-subpatterns) (map nil (function analyze-pattern) or-subpatterns)) (_ (error "lev...
control-flow
intermediate
0.9125
Define a macro that eliminates this repetitive pattern: (drelet nil) Issue: Macro call that should be transformed by DRELET
(drelet nil)
(defmacro DRELET ...)
(dynamic-relet nil)
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (define-condition/a dbi-error (simple-error) () (:documentation "Base class of all other error exceptions. Use this to catch all DBI errors.")) Pattern to recognize: Macro call that should be transformed by define-condition/a
(define-condition/a dbi-error (simple-error) () (:documentation "Base class of all other error exceptions. Use this to catch all DBI errors."))
(defmacro define-condition/a (name parent-types slots &body options) `(progn (define-condition ,name ,parent-types ,slots ,@options) (deftype ,(intern (format nil "<~A>" (symbol-name name))) () ',name) (setf (find-class ',(intern (format nil "<~A>" (symbol-name name)))) (find-class ',name)))...
(progn (define-condition dbi-error (simple-error) nil (:documentation "Base class of all other error exceptions. Use this to catch all DBI errors.")) (deftype <dbi-error> nil (quote dbi-error)) (setf (find-class (quote <dbi-error>)) (find-class (quote dbi-error))))
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (define-cruft %readtable-name (readtable) "Return the name associated with READTABLE." #+ :common-lisp (values (gethash readtable *readtable-names*))) Write a macro that addresses: Macro call that should be transformed by define-cruft
(define-cruft %readtable-name (readtable) "Return the name associated with READTABLE." #+ :common-lisp (values (gethash readtable *readtable-names*)))
(defmacro define-cruft (name lambda-list &body (docstring . alternatives)) (assert (typep docstring 'string) (docstring) "Docstring missing!") (assert (not (null alternatives))) `(progn (declaim (inline ,name)) (defun ,name ,lambda-list ,docstring ,(first alternatives))))
(progn (declaim (inline %readtable-name)) (defun %readtable-name (readtable) "Return the name associated with READTABLE." (values (gethash readtable *readtable-names*))))
efficiency
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: ;; Conditional logic with different variable bindings per branch ;; requires deeply nested lets inside each cond clause (cond ((> x 0) (let ((order :ascending) (bound (sqrt x))) (process order bound))) ((< x 0) (let (...
;; Conditional logic with different variable bindings per branch ;; requires deeply nested lets inside each cond clause (cond ((> x 0) (let ((order :ascending) (bound (sqrt x))) (process order bound))) ((< x 0) (let ((order :descending) (bound (sqrt (- x)))) ...
(defmacro condlet (clauses &body body) (let ((bodfn (gensym)) (vars (mapcar #'(lambda (v) (cons v (gensym))) (remove-duplicates (mapcar #'car (mappend #'cdr clauses)))))) `(labels ((,bodfn ,(mapcar #'car vars) ,...
;; (condlet (((= x 0) (order :zero) (bound 0)) ;; ((> x 0) (order :ascending) (bound (sqrt x))) ;; ((< x 0) (order :descending) (bound (sqrt (- x))))) ;; (process order bound)) ;; ;; Each cond clause specifies test + bindings. ;; The body (process order bound) is shared across all clauses. ;; Var...
control-flow
gensym,nested-backquote
intermediate
0.9625
Define a macro that eliminates this repetitive pattern: (with-hamt dict (:test test :hash hash :table table) (flet ((%insert (table key value) (%dict-insert table key value (funcall hash key) 0 test))) (make-instance 'hash-dict :test test :hash hash :table (labels ((f (table args) (if args (let ((key (car args)) (value...
(with-hamt dict (:test test :hash hash :table table) (flet ((%insert (table key value) (%dict-insert table key value (funcall hash key) 0 test))) (make-instance 'hash-dict :test test :hash hash :table (labels ((f (table args) (if args (let ((key (car args)) (value (cadr args))) (f (%insert table key value) (cddr args))...
(defmacro with-hamt (hamt (&key test hash table) &body body) "Accessing HAMT slots" `(with-accessors ((,test hamt-test) (,hash hamt-hash) (,table hamt-table)) ,hamt ,@body))
(with-accessors ((test hamt-test) (hash hamt-hash) (table hamt-table)) dict (flet ((%insert (table key value) (%dict-insert table key value (funcall hash key) 0 test))) (make-instance (quote hash-dict) :test test :hash hash :table (labels ((f (table args) (if args (let ((key (car args)) (value (cadr args))) (f (%insert...
control-flow
intermediate
0.9125
Define a macro that eliminates this repetitive pattern: (lret* () 1) Issue: Macro call that should be transformed by lret*
(lret* () 1)
(defmacro lret* ((&rest bindings) &body body) "Cf. `lret'." `(lret-aux let* ,bindings ,@body))
(lret-aux let* nil 1)
control-flow
intermediate
0.86
Write a Common Lisp macro to handle this code pattern: (dynamic-let* nil nil) Problem: Macro call that should be transformed by DYNAMIC-LET*
(dynamic-let* nil nil)
(defmacro DYNAMIC-LET* ...)
(progn nil)
control-flow
basic
0.7525
You are a Common Lisp macro expert. Given this code pattern: (defproto nil) Write a macro that addresses: Macro call that should be transformed by DEFPROTO
(defproto nil)
(defmacro DEFPROTO ...)
(progn (declaim (special nil)) (eval-when (:compile-toplevel)) (setf (symbol-value 'nil) (ensure-object (when (boundp 'nil) (symbol-value 'nil)) (list) :properties (list) :nickname 'nil)))
control-flow
basic
0.7525
Write a Common Lisp macro to handle this code pattern: (or nil nil) Problem: Macro call that should be transformed by OR
(or nil nil)
(defmacro OR ...)
(let ((#:g201 nil)) (if #:g201 #:g201 nil))
control-flow
basic
0.7525
Define a macro that eliminates this repetitive pattern: (with-shadowed-custom-vars (let ((tricky-json "{\"start_XPos\":98,\"start_YPos\":4}") (*json-symbols-package* (find-package :keyword))) (set-decoder-simple-list-semantics) (is (equal '((:START--*X-POS . 98) (:START--*Y-POS . 4)) (decode-json-from-string tricky-jso...
(with-shadowed-custom-vars (let ((tricky-json "{\"start_XPos\":98,\"start_YPos\":4}") (*json-symbols-package* (find-package :keyword))) (set-decoder-simple-list-semantics) (is (equal '((:START--*X-POS . 98) (:START--*Y-POS . 4)) (decode-json-from-string tricky-json)))))
(defmacro with-shadowed-custom-vars (&body body) `(let ,(loop for (var) in *custom-vars* collect `(,var (if (boundp ',var) ,var))) ,@body))
(let ((*aggregate-scope-variables* (if (boundp (quote *aggregate-scope-variables*)) *aggregate-scope-variables*)) (*string-scope-variables* (if (boundp (quote *string-scope-variables*)) *string-scope-variables*)) (*array-scope-variables* (if (boundp (quote *array-scope-variables*)) *array-scope-variables*)) (*object-sc...
control-flow
intermediate
0.9125
Generate a defmacro form that transforms code like this: (define-generic generic ((a a) (b b)) (+ a b)) Pattern to recognize: Macro call that should be transformed by define-generic
(define-generic generic ((a a) (b b)) (+ a b))
(defmacro define-generic (name (&rest arglist) &body body) "Convenience macro to define generics as if they were methods. ARGLIST can be a method arglist, in which case it's parsed into generic function arglist by removing method-specific args. BODY can be a list of `defgeneric' options (processed as-is, even :metho...
(prog1 (defgeneric generic (a b) (:method ((a a) (b b)) (+ a b))))
anaphoric
anaphor,recursive-expansion
advanced
0.9125
Write a Common Lisp macro to handle this code pattern: (with nil (progn)) Problem: Macro call that should be transformed by WITH
(with nil (progn))
(defmacro WITH ...)
(progn)
control-flow
basic
0.6825
You are a Common Lisp macro expert. Given this code pattern: (ok t) Write a macro that addresses: Macro call that should be transformed by ok
(ok t)
(defmacro ok (test &optional desc) (with-gensyms (duration result) (once-only (test desc) `(with-catching-errors (:expected T :description ,desc) (with-duration ((,duration ,result) ,test) (test ,result t ,desc :duration ,duration :test-fn (lambda (x y) ...
(let ((#:test142 t) (#:desc143 nil)) (with-catching-errors (:expected t :description #:desc143) (with-duration ((#:duration140 #:result141) #:test142) (test #:result141 t #:desc143 :duration #:duration140 :test-fn (lambda (x y) (eq (not (null x)) y)) :got-form #:test142))))
capture-management
once-only,gensym
intermediate
0.86
Define a macro that eliminates this repetitive pattern: (->> nil (progn)) Issue: Macro call that should be transformed by ->>
(->> nil (progn))
(defmacro ->> ...)
(progn nil)
control-flow
basic
0.7525
Create a Common Lisp macro for the following transformation. Before code: (collect-max nil) What needs to change: Macro call that should be transformed by COLLECT-MAX
(collect-max nil)
(defmacro COLLECT-MAX ...)
(common-lisp:let* ((#:generator-340 (generator nil)) #:numbers-334 (#:number-336 nil)) (declare (type generator #:generator-340)) (tagbody #:ll-341 (setq #:numbers-334 (next-in #:generator-340 (go end))) (if (or (null #:number-336) (< #:number-336 #:numbers-334)) ...
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (all-of nil) Pattern to recognize: Macro call that should be transformed by ALL-OF
(all-of nil)
(defmacro ALL-OF ...)
(lc (nil) always)
control-flow
basic
0.7525
Define a macro that eliminates this repetitive pattern: (quasiquote-unexpand-1 #-quasiquote-strict-append 'unquote-splicing #+quasiquote-strict-append 'x-unquote (car (last x))) Issue: Macro call that should be transformed by quasiquote
(quasiquote-unexpand-1 #-quasiquote-strict-append 'unquote-splicing #+quasiquote-strict-append 'x-unquote (car (last x)))
(defmacro quasiquote (x) (quasiquote-expand x))
(quasiquote-unexpand-1 (quote unquote-splicing) (car (last x)))
control-flow
recursive-expansion
basic
0.83
Define a macro that eliminates this repetitive pattern: (pop-preprocessor-directive-token token-list directive-symbol) Issue: Macro call that should be transformed by pop-preprocessor-directive-token
(pop-preprocessor-directive-token token-list directive-symbol)
(defmacro pop-preprocessor-directive-token (token-list directive-name &key (errorp t)) "Pops the next token in TOKEN-LIST ignoring `+whitespace-marker+'" (with-gensyms (head_) `(let ((,head_ (check-and-pop-pp-directive-token-1 ,token-list ,directive-name ,errorp))) (if (eq +whitespace-marker...
(let ((#:head_264 (check-and-pop-pp-directive-token-1 token-list directive-symbol t))) (if (eq +whitespace-marker+ #:head_264) (check-and-pop-pp-directive-token-1 token-list directive-symbol t) #:head_264))
capture-management
gensym
intermediate
0.9125
Write a Common Lisp macro to handle this code pattern: (define-op (:+ conjunctive-op)) Problem: Macro call that should be transformed by define-op
(define-op (:+ conjunctive-op))
(defmacro define-op ((op-name struct-type &key sql-op-name include-slots (package (find-package '#:sxql/operator))) &body body) (check-type op-name symbol) (let ((struct-name (intern (concatenate 'string (symbol-name op-name) #.(string :-op)) package))) `(defstruct (,struct-name (:include ,struct-type ...
(defstruct (+-op (:include conjunctive-op (name "+")) (:constructor make-+-op (&rest expressions))))
dsl
advanced
0.8875
Define a macro that eliminates this repetitive pattern: (inext-or-error nil) Issue: Macro call that should be transformed by INEXT-OR-ERROR
(inext-or-error nil)
(defmacro INEXT-OR-ERROR ...)
(let ((vals (multiple-value-list (funcall (i-coro nil) nil)))) (if (not vals) (error 'stop-iteration) (values (car vals) t)))
control-flow
basic
0.7525
You are a Common Lisp macro expert. Given this code pattern: (def-neo4j-fun add-to-index ((type :node) name key value object-id) :post (:uri-spec (format nil "index/~A/~A" (string-downcase (symbol-name type)) name)) (:encode (list (list (cons :uri object-id) (case type (:node :node-url) (:relationship :relationship-url...
(def-neo4j-fun add-to-index ((type :node) name key value object-id) :post (:uri-spec (format nil "index/~A/~A" (string-downcase (symbol-name type)) name)) (:encode (list (list (cons :uri object-id) (case type (:node :node-url) (:relationship :relationship-url))) (list (cons :key key)) (list (cons :value value))) :objec...
(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) ...
(progn (defun add-to-index (&key (type :node) name key value object-id) (let ((uri (format nil "index/~A/~A" (string-downcase (symbol-name type)) name)) (json (encode-neo4j-json-payload (list (list (cons :uri object-id) (case type (:node :node-url) (:relationship :relationship-url))) (list (cons :key key)) (list (cons ...
anaphoric
anaphor
intermediate
0.9125
Generate a defmacro form that transforms code like this: (*> +opt-fws+ +sliding-quoted-pairs+) Pattern to recognize: Macro call that should be transformed by *>
(*> +opt-fws+ +sliding-quoted-pairs+)
(defmacro *> (parser &rest parsers) "Combination of parsers yielding the result of the rightmost one." (let ((offset (gensym "*>-OFFSET"))) `(lambda (,offset) ,(reduce (lambda (i p) (let ((res (gensym "*>-RES")) (next (gensym "*>-NEXT"))) `(m...
(lambda (#:*>-offset149) (multiple-value-bind (#:*>-res150 #:*>-next151) (funcall +opt-fws+ #:*>-offset149) (if (ok? #:*>-res150) (funcall +sliding-quoted-pairs+ #:*>-next151) (fail #:*>-next151))))
control-flow
gensym
advanced
0.8875
Define a macro that eliminates this repetitive pattern: (resolve nil :key nil) Issue: Macro call that should be transformed by RESOLVE
(resolve nil :key nil)
(defmacro RESOLVE ...)
(locally (declare) (multiple-value-bind (#:assignment153 #:unified-p154) (type-unify 'nil 'nil (list)) (assert #:unified-p154 nil 'simple-type-error :format-control "gtypes failed to unify to the actual types:~% ~a~% against~% ~a" :format-arguments (list 'nil (list))) (let () ...
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (define-template nil (progn)) Pattern to recognize: Macro call that should be transformed by DEFINE-TEMPLATE
(define-template nil (progn))
(defmacro DEFINE-TEMPLATE ...)
(defmacro define-nil (&optional (#:name127)) (flet ((template-unfulfillable () (error 'template-unfulfillable :template 'nil :arguments (list)))) (declare (ignorable (function template-unfulfillable))) (let ((body (progn)) (name (or #:name127 (compose-name #\SOLIDUS 'nil)))) `(progn (...
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (as->* nil) Pattern to recognize: Macro call that should be transformed by AS->*
(as->* nil)
(defmacro AS->* ...)
(as-> nil)
control-flow
basic
0.7525
Write a Common Lisp macro to handle this code pattern: (defclass/std default () ((with-std))) Problem: Macro call that should be transformed by defclass/std
(defclass/std default () ((with-std)))
(defmacro defclass/std (name direct-superclasses direct-slots &rest options &environment env) "Shortcut macro to the DEFCLASS macro. (defclass/std example () ((slot1 slot2 slot3))) expands to: (DEFCLASS EXAMPLE () ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL) (SLO...
(defclass default nil ((with-std :accessor with-std :initarg :with-std :initform nil)))
control-flow
recursive-expansion
advanced
0.9125
Create a Common Lisp macro for the following transformation. Before code: (inext-noexit nil) What needs to change: Macro call that should be transformed by INEXT-NOEXIT
(inext-noexit nil)
(defmacro INEXT-NOEXIT ...)
(let ((vals (multiple-value-list (funcall (i-coro nil) nil)))) (if (not vals) (values nil nil) (values (car vals) t)))
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (make-obsolete mustache-render-to-string render* "0.10.0") Pattern to recognize: Macro call that should be transformed by make-obsolete
(make-obsolete mustache-render-to-string render* "0.10.0")
(defmacro make-obsolete (obsolete-name current-name when) `(defun ,obsolete-name (&rest args) ,(documentation current-name 'function) (warn 'deprecation-warning :name ',obsolete-name :replacement ',current-name :since ,when) (apply ',current-name args)))
(defun mustache-render-to-string (&rest args) #A((48) base-char . "Render TEMPLATE with optional CONTEXT to string.") (warn (quote deprecation-warning) :name (quote mustache-render-to-string) :replacement (quote render*) :since "0.10.0") (apply (quote render*) args))
control-flow
intermediate
0.9125
Define a macro that eliminates this repetitive pattern: (is (not (< 1 0))) Issue: Macro call that should be transformed by is
(is (not (< 1 0)))
(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 ch...
(let ((#:e185 1) (#:a186 0)) (if (progn (not (< #:e185 #:a186))) (add-result (quote test-passed) :test-expr (quote (not (< 1 0)))) (process-failure (quote (not (< 1 0))) "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)" (quote 0) #:a186 (quote <) #:e185)))
capture-management
gensym
advanced
0.8725
Create a Common Lisp macro for the following transformation. Before code: (undefmessage nil) What needs to change: Macro call that should be transformed by UNDEFMESSAGE
(undefmessage nil)
(defmacro UNDEFMESSAGE ...)
(fmakunbound 'nil)
control-flow
basic
0.7525
Write a Common Lisp macro to handle this code pattern: (with-assert-observers ("deleting bar" bar bar-1 baz) (store-remove :bar store)) Problem: Macro call that should be transformed by with-assert-observers
(with-assert-observers ("deleting bar" bar bar-1 baz) (store-remove :bar store))
(defmacro with-assert-observers ((desc &rest asserted-observers) &body body) `(let ((*observers* nil)) (trc ,desc " -- checking observers") ,@body (let ((superfluous-observers (loop for run in *observers* if (not (member run (list ,@asserted-observers))) collect run)) (failed-observers (loop for ...
(let ((*observers* nil)) (trc "deleting bar" " -- checking observers") (store-remove :bar store) (let ((superfluous-observers (loop for run in *observers* if (not (member run (list bar bar-1 baz))) collect run)) (failed-observers (loop for asserted in (list bar bar-1 baz) if (not (member asserted *observers*)) collect ...
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (do-matches (s e regex target-string count :start start :end end) (incf count)) Write a macro that addresses: Macro call that should be transformed by do-matches
(do-matches (s e regex target-string count :start start :end end) (incf count))
(defmacro do-matches ((match-start match-end regex target-string &optional result-form &key start end) &body body) "Iterates over TARGET-STRING and tries to match REGEX as often as possible e...
(do-scans (s e #:reg-starts137 #:reg-ends138 regex target-string count :start start :end end) (incf count))
anaphoric
anaphor
advanced
0.925
You are a Common Lisp macro expert. Given this code pattern: (incf nil) Write a macro that addresses: Macro call that should be transformed by INCF
(incf nil)
(defmacro INCF ...)
(setq nil (+ 1 nil))
control-flow
basic
0.7525
You are a Common Lisp macro expert. Given this code pattern: (with-html-string (:p (values "foo") "bar" "baz")) Write a macro that addresses: Macro call that should be transformed by with-html
(with-html-string (:p (values "foo") "bar" "baz"))
(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)))))
(with-output-to-string (*html*) (with-html (:p (values "foo") "bar" "baz")))
dsl
intermediate
0.875
Generate a defmacro form that transforms code like this: (ematch0 accessor ((list 'function name) name) ((list 'quote name) name) (_ (error "[access] 1st arg is not a function designator"))) Pattern to recognize: Macro call that should be transformed by ematch0
(ematch0 accessor ((list 'function name) name) ((list 'quote name) name) (_ (error "[access] 1st arg is not a function designator")))
(defmacro ematch0 (what &body clauses) `(match0 ,what ,@clauses (_ (error "level0 match error!"))))
(match0 accessor ((list (quote function) name) name) ((list (quote quote) name) name) (_ (error "[access] 1st arg is not a function designator")) (_ (error "level0 match error!")))
control-flow
intermediate
0.9125
Create a Common Lisp macro for the following transformation. Before code: (defmethod nil) What needs to change: Macro call that should be transformed by DEFMETHOD
(defmethod nil)
(defmacro DEFMETHOD ...)
(common-lisp:defmethod nil)
control-flow
basic
0.7525
Write a Common Lisp macro to handle this code pattern: (case 'some-name) Problem: Macro call that should be transformed by CASE
(case 'some-name)
(defmacro CASE ...)
(let ((#:g196 'some-name)) (declare (ignorable #:g196)) (cond))
control-flow
basic
0.7525
Create a Common Lisp macro for the following transformation. Before code: (all-of nil (progn)) What needs to change: Macro call that should be transformed by ALL-OF
(all-of nil (progn))
(defmacro ALL-OF ...)
(lc (nil (progn)) always)
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (continue-whopper 'some-name) Pattern to recognize: Macro call that should be transformed by CONTINUE-WHOPPER
(continue-whopper 'some-name)
(defmacro CONTINUE-WHOPPER ...)
(call-next-method-fn self class-env inst-env mcs%caller mcs%next-methods (list 'some-name))
control-flow
basic
0.7525
Define a macro that eliminates this repetitive pattern: (set-bop nil nil) Issue: Macro call that should be transformed by SET-BOP
(set-bop nil nil)
(defmacro SET-BOP ...)
(eval-when (:load-toplevel :compile-toplevel :execute) (progn (save-binfix) (mapc (lambda (ops) (mapc (lambda (op1) (when (eq (car op1) 'nil) (setf (cadr op1) 'nil) (unless t (setf (cddr op1) 'nil)))) ops)) *binfix*) (assign-properties)))
control-flow
basic
0.7525
Write a Common Lisp macro to handle this code pattern: (mvlet* (x) x) Problem: Macro call that should be transformed by mvlet*
(mvlet* (x) x)
(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 suffic...
(let* (x) x)
control-flow
recursive-expansion
advanced
0.8975
Create a Common Lisp macro for the following transformation. Before code: (when (not (node-slot body)) (format stream ";")) What needs to change: Macro call that should be transformed by when
(when (not (node-slot body)) (format stream ";"))
(defmacro when (test &body forms) `(if ,test ,(cl:if (cadr forms) `(progn ,@forms) (car forms))))
(if (not (node-slot body)) (format stream ";"))
control-flow
intermediate
0.875
Create a Common Lisp macro for the following transformation. Before code: (ematch0 clause ((list* patterns body) (list* (expand-multipatterns patterns) body))) What needs to change: Macro call that should be transformed by ematch0
(ematch0 clause ((list* patterns body) (list* (expand-multipatterns patterns) body)))
(defmacro ematch0 (what &body clauses) `(match0 ,what ,@clauses (_ (error "level0 match error!"))))
(match0 clause ((list* patterns body) (list* (expand-multipatterns patterns) body)) (_ (error "level0 match error!")))
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (make-simple-collector-to-place nil) Write a macro that addresses: Macro call that should be transformed by MAKE-SIMPLE-COLLECTOR-TO-PLACE
(make-simple-collector-to-place nil)
(defmacro MAKE-SIMPLE-COLLECTOR-TO-PLACE ...)
(progn (setf nil (alexandria:ensure-list nil)) (let* ((#:tail123 (last nil))) (lambda (&rest values) (collect-at-end nil #:tail123 values) nil)))
control-flow
basic
0.7675
Create a Common Lisp macro for the following transformation. Before code: (with-prepared-query query (*connection* sql :use-prepare-cached *use-prepare-cached*) (setf query (execute-with-retry query binds)) (query-row-count query)) What needs to change: Macro call that should be transformed by with-prepared-query
(with-prepared-query query (*connection* sql :use-prepare-cached *use-prepare-cached*) (setf query (execute-with-retry query binds)) (query-row-count query))
(defmacro with-prepared-query (query (conn sql &key use-prepare-cached) &body body) `(call-with-prepared-query ,conn ,sql (lambda (,query) ,@body) :use-prepare-cached ,use-prepare-cached))
(call-with-prepared-query *connection* sql (lambda (query) (setf query (execute-with-retry query binds)) (query-row-count query)) :use-prepare-cached *use-prepare-cached*)
dsl
basic
0.805
Create a Common Lisp macro for the following transformation. Before code: (is (= a (dummy-add a 0))) What needs to change: Macro call that should be transformed by is
(is (= a (dummy-add a 0)))
(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 ch...
(let ((#:e155 a) (#:a156 (dummy-add a 0))) (if (progn (= #:e155 #:a156)) (add-result (quote test-passed) :test-expr (quote (= a (dummy-add a 0)))) (process-failure (quote (= a (dummy-add a 0))) "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%" (quote (dummy-add a 0)) #:a156 (quote =) #:e155)))
capture-management
gensym
advanced
0.8725
Generate a defmacro form that transforms code like this: (define-script-symbol-macro nil nil) Pattern to recognize: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO
(define-script-symbol-macro nil nil)
(defmacro DEFINE-SCRIPT-SYMBOL-MACRO ...)
(define-ps-symbol-macro nil nil)
control-flow
basic
0.7675
Write a Common Lisp macro to handle this code pattern: (is-print (princ "ABCDEFGH") "ABCDEFGHIJKLMNO") Problem: Macro call that should be transformed by is-print
(is-print (princ "ABCDEFGH") "ABCDEFGHIJKLMNO")
(defmacro is-print (got expected &optional desc) (with-gensyms (output duration duration-inner) (once-only (expected desc) `(with-catching-errors (:description ,desc :expected ,expected) (let* (,duration (,output (with-output-to-string (*standard-output*) ...
(let ((#:expected203 "ABCDEFGHIJKLMNO") (#:desc204 nil)) (with-catching-errors (:description #:desc204 :expected #:expected203) (let* (#:duration201 (#:output200 (with-output-to-string (*standard-output*) (with-duration ((#:duration-inner202 #:output200) (princ "ABCDEFGH")) (declare (ignore #:output200)) (setq #:durati...
capture-management
once-only,gensym
intermediate
0.875
Define a macro that eliminates this repetitive pattern: (define-hook-type string->string (function (string) string) "Hook that takes a string and produces a new one.") Issue: Macro call that should be transformed by define-hook-type
(define-hook-type string->string (function (string) string) "Hook that takes a string and produces a new one.")
(defmacro define-hook-type (name type &optional documentation) "Define hook class. Type must be something like: (function (string) (values integer t)) The `handler-type' of the defined hook class has `:class' allocation type, so that all hooks of such class have the same `handler-type'." (let* ((name (string na...
(defclass hook-string->string (hook) ((handler-type :initform (quote (function (string) string)) :allocation :class)) (:metaclass sb-mop:funcallable-standard-class) (:documentation "Hook that takes a string and produces a new one."))
control-flow
advanced
0.925
You are a Common Lisp macro expert. Given this code pattern: (-<> -<>> some-<> some-<>>) Write a macro that addresses: Macro call that should be transformed by -<>
(-<> -<>> some-<> some-<>>)
(defmacro -<> (init &body exps) (diamond-wand init exps))
(block #:g122 (block #:g121 -<>>))
control-flow
basic
0.7525
Generate a defmacro form that transforms code like this: (defclass/std example () ((slot1 slot2 slot3))) Pattern to recognize: Macro call that should be transformed by defclass/std
(defclass/std example () ((slot1 slot2 slot3)))
(defmacro defclass/std (name direct-superclasses direct-slots &rest options &environment env) "Shortcut macro to the DEFCLASS macro. (defclass/std example () ((slot1 slot2 slot3))) expands to: (DEFCLASS EXAMPLE () ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL) (SLO...
(defclass example nil ((slot1 :accessor slot1 :initarg :slot1 :initform nil) (slot2 :accessor slot2 :initarg :slot2 :initform nil) (slot3 :accessor slot3 :initarg :slot3 :initform nil)))
control-flow
recursive-expansion
advanced
0.9125
Create a Common Lisp macro for the following transformation. Before code: (-> :g () 2) What needs to change: Macro call that should be transformed by ->
(-> :g () 2)
(defmacro -> (invariant &body args) "See flow:atomically" `(atomically ,invariant ,@args))
(atomically :g nil 2)
control-flow
basic
0.8225
Define a macro that eliminates this repetitive pattern: (with-log-error-handling () (with-wcs-math-error-handling (ret (log1+ x)) (check-wcs-math-result))) Issue: Macro call that should be transformed by with-log-error-handling
(with-log-error-handling () (with-wcs-math-error-handling (ret (log1+ x)) (check-wcs-math-result)))
(defmacro with-log-error-handling (() &body body) `(handler-case (progn ,@body) #+allegro ;; TODO: rewrite other `simple-error' handler to use arithmetic-error. (arithmetic-error (e) (let ((operands (arithmetic-error-operands e))) (cond ((zerop (first operands)) (wcs-rai...
(handler-case (progn (with-wcs-math-error-handling (ret (log1+ x)) (check-wcs-math-result))))
control-flow
intermediate
0.9125
Write a Common Lisp macro to handle this code pattern: (signal-reader-error "Could not find character with name '~A'" name) Problem: Macro call that should be transformed by signal-reader-error
(signal-reader-error "Could not find character with name '~A'" name)
(defmacro signal-reader-error (format-control &rest format-arguments) "Like ERROR but signals a SIMPLE-READER-ERROR for the stream *STREAM*." `(error 'simple-reader-error :stream *stream* :format-control ,format-control :format-arguments (list ,@format-arguments)))
(error (quote simple-reader-error) :stream *stream* :format-control "Could not find character with name '~A'" :format-arguments (list name))
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (define-class some-class (some super classes) ((slot1 :unbound)) (1 2) (:accessor-name-transformer (make-name-transformer name "-ZORK")) (3 4)) Write a macro that addresses: Macro call that should be transformed by define-class
(define-class some-class (some super classes) ((slot1 :unbound)) (1 2) (:accessor-name-transformer (make-name-transformer name "-ZORK")) (3 4))
(defmacro define-class (name supers slots &rest options) "Convenience wrapper of `defclass'. It automates a lot of boilerplate (like exporting all the accessors of a class) plus adds some new features. Slot options: - The initform can be specified as the second value. - `:accessor', `:reader' and `:writer' can ...
(progn (defclass some-class (some super classes) ((slot1 :accessor slot1-zork :initarg :slot1)) (1 2) (3 4)) (unless (fboundp (quote some-class-p)) (define-generic some-class-p (object) #A((75) base-char . "Auto-generated predicate for whether OBJECT is an instance of `some-class'.") (declare (sb-ext:muffle-conditions ...
control-flow
advanced
0.925
Define a macro that eliminates this repetitive pattern: (defclass/std unknown () ((slot :wi :unknown keywords :and values))) Issue: Macro call that should be transformed by defclass/std
(defclass/std unknown () ((slot :wi :unknown keywords :and values)))
(defmacro defclass/std (name direct-superclasses direct-slots &rest options &environment env) "Shortcut macro to the DEFCLASS macro. (defclass/std example () ((slot1 slot2 slot3))) expands to: (DEFCLASS EXAMPLE () ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL) (SLO...
(defclass unknown nil ((slot :writer slot :initarg :slot :initform nil :unknown keywords :and values)))
control-flow
recursive-expansion
advanced
0.95
You are a Common Lisp macro expert. Given this code pattern: (def-dynenv-fun nil (progn)) Write a macro that addresses: Macro call that should be transformed by DEF-DYNENV-FUN
(def-dynenv-fun nil (progn))
(defmacro DEF-DYNENV-FUN ...)
(eval-when (:compile-toplevel :load-toplevel :execute) (defun nil (&rest #:args) (apply (dynenv-function nil) #:args)) (defvar #:nil144 (lambda (progn))) (setf (get 'nil 'dynenv-fun) '#:nil144))
control-flow
basic
0.7675
Write a Common Lisp macro to handle this code pattern: (mapping nil (progn)) Problem: Macro call that should be transformed by MAPPING
(mapping nil (progn))
(defmacro MAPPING ...)
(mapping-mac nil (progn))
control-flow
basic
0.7525
Create a Common Lisp macro for the following transformation. Before code: (defsyntax nil nil) What needs to change: Macro call that should be transformed by DEFSYNTAX
(defsyntax nil nil)
(defmacro defsyntax (name &body options) `(progn (setf (get ',name :options) ',options) (defvar ,name (defreadtable ,name ,@options))))
(progn (setf (get 'nil :options) '(nil)) (defvar nil (defreadtable nil nil)))
control-flow
intermediate
0.86
Write a Common Lisp macro to handle this code pattern: (builder (:auth-basic :authenticator (lambda (user pass) (declare (ignore user pass)) t)) *app*) Problem: Macro call that should be transformed by builder
(builder (:auth-basic :authenticator (lambda (user pass) (declare (ignore user pass)) t)) *app*)
(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-for...
(reduce (function funcall) (remove-if (function null) (list (lambda (#:app174) (funcall (find-middleware :auth-basic) #:app174 :authenticator (lambda (user pass) (declare (ignore user pass)) t))))) :initial-value (to-app *app*) :from-end t)
control-flow
intermediate
0.9125
Define a macro that eliminates this repetitive pattern: (defclass/a dbi-connection () ((auto-commit :type boolean :initarg :auto-commit :initform t) (database-name :initarg :database-name :accessor connection-database-name) (%handle :initarg :handle :accessor connection-handle) (query-cache :initform (make-hash-table :...
(defclass/a dbi-connection () ((auto-commit :type boolean :initarg :auto-commit :initform t) (database-name :initarg :database-name :accessor connection-database-name) (%handle :initarg :handle :accessor connection-handle) (query-cache :initform (make-hash-table :test 'equal) :accessor connection-query-cache) (establis...
(defmacro defclass/a (name superclasses slots &rest class-options) `(progn (defclass ,name ,superclasses ,slots ,@class-options) (deftype ,(intern (format nil "<~A>" (symbol-name name))) () ',name) (setf (find-class ',(intern (format nil "<~A>" (symbol-name name)))) (find-class ',name))))
(progn (defclass dbi-connection nil ((auto-commit :type boolean :initarg :auto-commit :initform t) (database-name :initarg :database-name :accessor connection-database-name) (%handle :initarg :handle :accessor connection-handle) (query-cache :initform (make-hash-table :test (quote equal)) :accessor connection-query-cac...
control-flow
intermediate
0.9125
You are a Common Lisp macro expert. Given this code pattern: (with-cached-reader-conditionals nil (progn)) Write a macro that addresses: Macro call that should be transformed by WITH-CACHED-READER-CONDITIONALS
(with-cached-reader-conditionals nil (progn))
(defmacro WITH-CACHED-READER-CONDITIONALS ...)
(call-with-cached-reader-conditionals (lambda () nil (progn)))
control-flow
basic
0.7675
Create a Common Lisp macro for the following transformation. Before code: (with-yield-binds (format nil "~A(~{~A~^, ~})" (sql-op-name op) (mapcar #'yield (function-op-expressions op)))) What needs to change: Macro call that should be transformed by with-yield-binds
(with-yield-binds (format nil "~A(~{~A~^, ~})" (sql-op-name op) (mapcar #'yield (function-op-expressions op))))
(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))))
(let ((*bind-values* nil) (*use-global-bind-values* t)) (values (progn (format nil "~A(~{~A~^, ~})" (sql-op-name op) (mapcar (function yield) (function-op-expressions op)))) (loop for bind in (reverse *bind-values*) append bind)))
control-flow
intermediate
0.9125
Create a Common Lisp macro for the following transformation. Before code: (when-let ((x 1) (y nil) (z 3)) :oops) What needs to change: Macro call that should be transformed by when-let
(when-let ((x 1) (y nil) (z 3)) :oops)
(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...
(let ((x 1) (y nil) (z 3)) (when (and x y z) :oops))
control-flow
advanced
0.8875
Create a Common Lisp macro for the following transformation. Before code: (with-quote-char (sxql:yield sql)) What needs to change: Macro call that should be transformed by with-quote-char
(with-quote-char (sxql:yield sql))
(defmacro with-quote-char (&body body) `(let ((sxql:*quote-character* (or sxql:*quote-character* (connection-quote-character)))) ,@body))
(let ((*quote-character* (or *quote-character* (connection-quote-character)))) (sxql/sql-type:yield sql))
control-flow
intermediate
0.875
Write a Common Lisp macro to handle this code pattern: (with-fixtures (fixtures test) (call-next-method)) Problem: Macro call that should be transformed by with-fixtures
(with-fixtures (fixtures test) (call-next-method))
(defmacro with-fixtures (fixtures &body body) `(call-with-fixtures (lambda () ,@body) ,fixtures))
(call-with-fixtures (lambda nil (call-next-method)) (fixtures test))
control-flow
basic
0.7675
Write a Common Lisp macro to handle this code pattern: (-> nil () 0) Problem: Macro call that should be transformed by ->
(-> nil () 0)
(defmacro -> (invariant &body args) "See flow:atomically" `(atomically ,invariant ,@args))
(atomically nil nil 0)
control-flow
basic
0.8225
End of preview.

Common Lisp Macro Transformations

A fine-tuning dataset for training models to generate Common Lisp macros. Each example is a call-form, macro-definition, and expanded-form triple.

Summary

  • 4,267 examples from 120+ Common Lisp libraries
  • Split: 2,985 train / 637 validation / 645 test
  • Format: JSONL with instruction, input, output, category, technique, complexity, quality_score
  • Mean quality score: 0.80
  • Sources: Let Over Lambda, On Lisp, Alexandria, Serapeum, Iterate, Trivia, Parenscript, CFFI, CL-PPCRE, and 110+ more from Quicklisp and awesome-cl

Task

Train a model (<=32B parameters) to generate Common Lisp macro definitions. Given a code pattern or macro call, the model produces the defmacro form that performs the transformation.

This is fundamentally different from code generation -- macros are code that writes code.

Usage

from datasets import load_dataset
ds = load_dataset("j14i/cl-macros", split="train")

Generation Pipeline

Macros are discovered via SBCL + Quicklisp: do-external-symbols finds all exported macros, synthetic call forms are generated, macroexpand-1 verifies expansions, and a Python classifier auto-labels technique, category, and complexity.

Downloads last month
60