Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by
Hi! I have a small documentation improvement proposal:

When using regular `defn` to create a relation, I've found that an empty {{(fresh [] ...)}} is needed if you want to use multiple relations and goals inside your defn:ed relation, otherwise your goals are in the implicit do from defn, and only the last one has any effect.

Simple example:

{{
defn-logic> (defn test [a b]
              (== a 1)
              (== b 2))
#'defn-logic/test
defn-logic> (run* [q] (fresh [a b]
                        (== q [a b])
                        (test a b)))
([_0 2])
defn-logic> (defn test [a b]
              (fresh []
                (== a 1)
                (== b 2)))
#'defn-logic/test
defn-logic> (run* [q] (fresh [a b]
                        (== q [a b])
                        (test a b)))
([1 2])
defn-logic>
}}

Again, this is perfectly correct and reasonable, but maybe a bit confusing for beginners, in that the implicit do "fails silently". What I'm looking for here is probably just a heads up in the Wiki docs. I couldn't find it, but maybe it exists already? I'd be happy to add it to the documentation and send a PR.

3 Answers

0 votes
by

Comment made by: owickstrom

The REPL session got messed up, now attached as a file instead.

0 votes
by

Comment made by: owickstrom

Oh, I just found all (http://clojuredocs.org/clojure.core.logic/all) which seems to be preferred over (fresh (link: ) ...).

0 votes
by
Reference: https://clojure.atlassian.net/browse/LOGIC-179 (reported by owickstrom)
...