Skip to content

Instantly share code, notes, and snippets.

@NoahTheDuke
Created July 9, 2025 15:31
Show Gist options
  • Save NoahTheDuke/bb0cd8c7a783e11a2aa6cc847f2f65f9 to your computer and use it in GitHub Desktop.
Save NoahTheDuke/bb0cd8c7a783e11a2aa6cc847f2f65f9 to your computer and use it in GitHub Desktop.
Demonstration of input/output of pattern macro
(read-form 'ctx-123 '(into [(?* args)] (?trans (?? f) ?coll)) 'form-123)
;; returns
(clojure.core/let
[simple-seq-form-40240 form-123]
(clojure.core/and
(clojure.core/list? simple-seq-form-40240)
(clojure.core/= 3 (clojure.core/count simple-seq-form-40240))
(clojure.core/let
[ctx-123
(clojure.core/when
(clojure.core/and
ctx-123
(clojure.core/seq simple-seq-form-40240))
(clojure.core/when
(clojure.core/= 'into (clojure.core/first simple-seq-form-40240))
ctx-123))
simple-seq-form-40240
(clojure.core/when
ctx-123
(clojure.core/next simple-seq-form-40240))
ctx-123
(clojure.core/when
(clojure.core/and
ctx-123
(clojure.core/seq simple-seq-form-40240))
(clojure.core/let
[variable-seq-form-40241
(clojure.core/first simple-seq-form-40240)]
(clojure.core/and
(clojure.core/vector? variable-seq-form-40241)
(clojure.core/<= 0 (clojure.core/count variable-seq-form-40241))
(clojure.core/let
[star-rest-fn-40243
(clojure.core/fn
star-rest-fn-40243
[ctx-123 form__5968__auto__ cont__5969__auto__]
(clojure.core/let
[star-rest-form-40242
(clojure.core/vary-meta
(clojure.core/vec form__5968__auto__)
clojure.core/assoc
:noahtheduke.splint.pattern/rest
true)]
(clojure.core/when
true
(clojure.core/let
[ctx-123
(if
(#{'?_ '_} '?args)
ctx-123
(clojure.core/let
[bind-form-40244 star-rest-form-40242]
(clojure.core/if-let
[existing__5956__auto__
(clojure.core/find ctx-123 '?args)]
(clojure.core/when
(clojure.core/=
(clojure.core/val existing__5956__auto__)
bind-form-40244)
ctx-123)
(clojure.core/assoc
ctx-123
'?args
bind-form-40244))))]
(cont__5969__auto__ ctx-123 nil)))))]
(noahtheduke.splint.pattern/seq-match-step
ctx-123
variable-seq-form-40241
[star-rest-fn-40243])))))
simple-seq-form-40240
(clojure.core/when
ctx-123
(clojure.core/next simple-seq-form-40240))
ctx-123
(clojure.core/when
(clojure.core/and
ctx-123
(clojure.core/seq simple-seq-form-40240))
(clojure.core/let
[variable-seq-form-40245
(clojure.core/first simple-seq-form-40240)]
(clojure.core/and
(clojure.core/list? variable-seq-form-40245)
(clojure.core/<= 2 (clojure.core/count variable-seq-form-40245))
(clojure.core/let
[single-fn-40248
(clojure.core/fn
single-fn-40248
[ctx-123 many-normal-form-40246 cont__6047__auto__]
(clojure.core/let
[ctx-123
(clojure.core/when
(clojure.core/and
ctx-123
(clojure.core/seq many-normal-form-40246))
(if
(#{'?_ '_} '?trans)
ctx-123
(clojure.core/let
[bind-form-40247
(clojure.core/first many-normal-form-40246)]
(clojure.core/if-let
[existing__5956__auto__
(clojure.core/find ctx-123 '?trans)]
(clojure.core/when
(clojure.core/=
(clojure.core/val existing__5956__auto__)
bind-form-40247)
ctx-123)
(clojure.core/assoc
ctx-123
'?trans
bind-form-40247)))))
many-normal-form-40246
(clojure.core/when
ctx-123
(clojure.core/next many-normal-form-40246))]
(clojure.core/when
ctx-123
(cont__6047__auto__ ctx-123 many-normal-form-40246))))
optional-fn-40250
(clojure.core/fn
optional-fn-40250
[ctx-123 form__6018__auto__ cont__6019__auto__]
(clojure.core/let
[optional-form-40249 []]
(clojure.core/or
(clojure.core/when
(clojure.core/seq form__6018__auto__)
(clojure.core/let
[optional-form-40249
(clojure.core/vary-meta
(clojure.core/vec
(clojure.core/take 1 form__6018__auto__))
clojure.core/assoc
:noahtheduke.splint.pattern/rest
true)]
(clojure.core/when
true
(clojure.core/let
[ctx__6020__auto__
(if
(#{'?_ '_} '?f)
ctx-123
(clojure.core/let
[bind-form-40251 optional-form-40249]
(clojure.core/if-let
[existing__5956__auto__
(clojure.core/find ctx-123 '?f)]
(clojure.core/when
(clojure.core/=
(clojure.core/val existing__5956__auto__)
bind-form-40251)
ctx-123)
(clojure.core/assoc
ctx-123
'?f
bind-form-40251))))]
(cont__6019__auto__
ctx__6020__auto__
(clojure.core/drop 1 form__6018__auto__))))))
(clojure.core/and
true
(clojure.core/let
[ctx__6020__auto__
(if
(#{'?_ '_} '?f)
ctx-123
(clojure.core/let
[bind-form-40252 optional-form-40249]
(clojure.core/if-let
[existing__5956__auto__
(clojure.core/find ctx-123 '?f)]
(clojure.core/when
(clojure.core/=
(clojure.core/val existing__5956__auto__)
bind-form-40252)
ctx-123)
(clojure.core/assoc ctx-123 '?f bind-form-40252))))]
(cont__6019__auto__
ctx__6020__auto__
form__6018__auto__))))))
single-fn-40255
(clojure.core/fn
single-fn-40255
[ctx-123 many-normal-form-40253 cont__6047__auto__]
(clojure.core/let
[ctx-123
(clojure.core/when
(clojure.core/and
ctx-123
(clojure.core/seq many-normal-form-40253))
(if
(#{'?_ '_} '?coll)
ctx-123
(clojure.core/let
[bind-form-40254
(clojure.core/first many-normal-form-40253)]
(clojure.core/if-let
[existing__5956__auto__
(clojure.core/find ctx-123 '?coll)]
(clojure.core/when
(clojure.core/=
(clojure.core/val existing__5956__auto__)
bind-form-40254)
ctx-123)
(clojure.core/assoc ctx-123 '?coll bind-form-40254)))))
many-normal-form-40253
(clojure.core/when
ctx-123
(clojure.core/next many-normal-form-40253))]
(clojure.core/when
ctx-123
(cont__6047__auto__ ctx-123 many-normal-form-40253))))]
(noahtheduke.splint.pattern/seq-match-step
ctx-123
variable-seq-form-40245
[single-fn-40248 optional-fn-40250 single-fn-40255])))))
simple-seq-form-40240
(clojure.core/when
ctx-123
(clojure.core/next simple-seq-form-40240))]
ctx-123)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment