Skip to content

Instantly share code, notes, and snippets.

@datajohnny

datajohnny/core.clj

Created Jan 13, 2016
Embed
What would you like to do?
clara issue
(ns ruler.core
(:gen-class)
(:require [clara.rules :refer :all]
[clara.tools.inspect :refer :all]))
(defrecord Person [name age])
(defrule is-adult
[Person (>= 21 age)]
=>
(insert! (->Person)))
(defquery get-persons
[]
[?person <- Person])
(defn print-persons
[session]
(doseq [{{name :name age :age} :?person} (query session get-persons)]
(println name " " age))
session)
(defn -main
"I don't do a whole lot ... yet."
[& args]
(-> (mk-session 'ruler.core)
(insert (->Person "Eric" 21))
(fire-rules)
(print-persons)))
Exception in thread "main" clojure.lang.ExceptionInfo: Exception in ruler.core/is-adult with bindings {} {:bindings {}, :name "ruler.core/is-adult", :rhs (do (clara.rules/insert! (ruler.core/->Person)))}, compiling:(/private/var/folders/5f/hzlntck12cj5mrlyd6j6ddkw0000gn/T/form-init175911532377559672.clj:1:124)
at clojure.lang.Compiler.load(Compiler.java:7239)
at clojure.lang.Compiler.loadFile(Compiler.java:7165)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invoke(main.clj:308)
at clojure.main$null_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: clojure.lang.ExceptionInfo: Exception in ruler.core/is-adult with bindings {} {:bindings {}, :name "ruler.core/is-adult", :rhs (do (clara.rules/insert! (ruler.core/->Person)))}
at clojure.core$ex_info.invoke(core.clj:4593)
at clara.rules.engine$fire_rules_STAR_$fn__4518$fn__4519.invoke(engine.cljc:1057)
at clara.rules.engine$fire_rules_STAR_$fn__4518.invoke(engine.cljc:1047)
at clara.rules.engine$fire_rules_STAR_.invoke(engine.cljc:1044)
at clara.rules.engine.LocalSession.fire_rules(engine.cljc:1117)
at clara.rules$fire_rules.invoke(rules.cljc:35)
at ruler.core$_main.doInvoke(core.clj:28)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.Var.invoke(Var.java:375)
at user$eval5.invoke(form-init175911532377559672.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6782)
at clojure.lang.Compiler.eval(Compiler.java:6772)
at clojure.lang.Compiler.load(Compiler.java:7227)
... 11 more
Caused by: clojure.lang.ArityException: Wrong number of args (0) passed to: core/eval6101/->Person--6116
at clojure.lang.AFn.throwArity(AFn.java:429)
at clojure.lang.AFn.invoke(AFn.java:28)
at user$eval6139$fn__6140.invoke(form-init175911532377559672.clj:1)
at clara.rules.engine$fire_rules_STAR_$fn__4518$fn__4519.invoke(engine.cljc:1048)
... 22 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.