From f51e3059220e56b983d859e77597eeca4a0ee120 Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Sun, 26 Mar 2023 11:06:40 -0700 Subject: [PATCH] feat: add compiler macro for functionalize --- lens.lisp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lens.lisp b/lens.lisp index b074ec9..a24ed2b 100644 --- a/lens.lisp +++ b/lens.lisp @@ -24,6 +24,16 @@ (:method ((it function)) it)) +(define-compiler-macro functionalize (&whole whole it) + (typecase it + (cons (destructuring-bind (h . tail) it + (declare (ignore tail)) + (case h + (quote it) + (function it) + (t whole)))) + (t whole))) + ;;; TODO: consider making this wrap defalias? (defmacro shortcut (name function &body bound-args) `(eval-when (:load-toplevel :compile-toplevel :execute)