This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-02
Channels
- # adventofcode (6)
- # announcements (6)
- # babashka (21)
- # babashka-sci-dev (18)
- # biff (6)
- # clara (4)
- # clj-commons (2)
- # clj-kondo (7)
- # cljdoc (4)
- # clojure (9)
- # clojure-berlin (8)
- # clojure-europe (23)
- # clojure-gamedev (3)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-poland (1)
- # clojurescript (27)
- # community-development (1)
- # conjure (32)
- # etaoin (6)
- # events (20)
- # fulcro (5)
- # graalvm (1)
- # helix (19)
- # hyperfiddle (14)
- # introduce-yourself (2)
- # music (1)
- # nbb (24)
- # off-topic (37)
- # pathom (2)
- # polylith (14)
- # reagent (11)
- # releases (1)
- # remote-jobs (1)
- # reveal (22)
- # shadow-cljs (16)
- # sql (3)
- # squint (11)
- # test-check (2)
- # xtdb (36)
Hey! Anyone knows why I get this error?
1. Unhandled java.lang.IllegalArgumentException
The query {:lhs [{:type repl.Cold, :constraints [], :fact-binding :?cold}],
:params #{}, :name "repl/cold?"} is invalid or not included in the rule base.
My code looks like this:
(ns repl
(:require
[clara.rules :refer [defquery defrule fire-rules insert insert! query mk-session]]))
(defrecord Temperature [temperature])
(defrecord Cold [temperature])
(defquery cold? [] [?cold <- Cold])
(let [session-with-rules
(mk-session
[(quote
{:ns-name repl,
:lhs [{:type repl.Temperature,
:constraints [(= ?temperature temperature) (< temperature -20)]}],
:rhs (do (insert! (->Cold ?temperature))),
:name "repl/cold-rule"})])
session-with-rules-and-facts
(insert
session-with-rules
(Temperature. -21))
evaluated-session
(fire-rules session-with-rules-and-facts)]
(query evaluated-session cold?))
Hey @UAEV0STAA, I believe that the error you mentioned is occurring, because during construction of the session only the “temperature” production is being provided. I believe that the mk-session
call should look something like:
(mk-session
[(quote
{:ns-name repl,
:lhs [{:type repl.Temperature,
:constraints [(= ?temperature temperature) (< temperature -20)]}],
:rhs (do (insert! (->Cold ?temperature))),
:name "repl/cold-rule"})
cold?])