core-logic

Josh Munn 2026-02-23T17:03:17.415379Z

For some reason (likely influenced by https://stackoverflow.com/a/50042635) I thought that I needed to prefix vars in defne/matche patterns with ? to have them be implicitly declared, but it seems that is not the case. It's mentioned in the https://github.com/clojure/core.logic/blob/master/CHANGES.md#enhancements-11 facepalm

Josh Munn 2026-02-23T17:03:53.365489Z

> (macroexpand '(l/defne test-rel [a b]
                                           ([a [c . d]] (other-rel a d))))
(def
  test-rel
  (clojure.core.logic/fnm
   clojure.core.logic/conde
   [a b]
   ([a [c . d]] (other-rel a d))))
> (macroexpand '(clojure.core.logic/fnm
                                          clojure.core.logic/conde
                                          [a b]
                                          ([a [c . d]] (other-rel a d))))
(fn*
 ([a b]
  (clojure.core.logic/conde
   ((clojure.core.logic/fresh
     []
     (clojure.core.logic/== a a)
     (clojure.core.logic/fresh
      [c d]
      (clojure.core.logic/== (clojure.core.logic/llist c d) b)
      (other-rel a d)))))))

Josh Munn 2026-02-23T17:04:17.436999Z

It's clear from the fresh block.