![](/img/trans.png)
[英]Clara rules: Is it possible to extract defrecord-s into a separate Clojure namespace?
[英]Unable to run clara rules clojure program from eclipse
我正在尝试学习clara规则-“ http://www.clara-rules.org/docs/firststeps/ ”中提供的clojure
(ns with-mongo.clara.example
(:require [clara.rules :refer :all]))
(defrecord SupportRequest [client level])
(defrecord ClientRepresentative [name client])
(defrule is-important
"Find important support requests."
[SupportRequest (= :high level)]
=>
(println "High support requested!"))
(defrule notify-client-rep
"Find the client representative and request support."
[SupportRequest (= ?client client)]
[ClientRepresentative (= ?client client) (= ?name name)]
=>
(println "Notify" ?name "that"
?client "has a new support request!"))
在REPL中执行以下操作
(-> (mk-session 'with-mongo.clara.example)
(insert (->ClientRepresentative "Alice" "Acme")
(->SupportRequest "Acme" :high))
(fire-rules))
但是我在eclipse中得到的是CompilerException java.lang.RuntimeException:无法解析符号:在这种情况下的火灾规则,编译:(C:\\ Users \\ x \\ AppData \\ Local \\ Temp \\ form-init8304513432405616575.clj:1: 2)
有人有任何细节吗?
您require
在REPL中预先提供d clara.rules
。 例如运行
(require '[clara.rules :refer :all]))
第一。 (或者首先在那儿运行自己的ns
这取决于您要如何运行/使用REPL以及什么eclipse允许您使用(此处为非eclipse用户))
那么,为什么它抱怨fire-rules
而不是mk-session
呢? 那是由于线程宏->
工作方式。 如果您对代码进行macroexpand
,那么您将看到, fire-rules
实际上是第一个调用的函数。
我面临的问题是由于版本不匹配
:dependencies [[org.clojure/clojure "1.6.0"]
[com.novemberain/monger "3.0.0-rc2"]
[ring "1.4.0"]
[ring/ring-json "0.4.0"]
[compojure "1.4.0"]
[com.cerner/clara-rules "0.19.0"]])
我正在使用1.6.0制作Clojure,并更新到Clojure“ 1.7.0”之后。 克拉拉规则被触发。
:dependencies [[org.clojure/clojure "1.7.0"]
[com.novemberain/monger "3.0.0-rc2"]
[ring "1.4.0"]
[ring/ring-json "0.4.0"]
[compojure "1.4.0"]
[com.cerner/clara-rules "0.19.0"]])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.