我无法通过clojure识别core.logic库中的 defrel 。因此,在使用lein(和compojure)设置项目并使core.logic 运行* 工作之后,我尝试了一个使用 defrel 的简单示例......下面是生成的标题包括:使用clojure.core.logic和失败的行(请参阅http://objectcommando.com/blog/2011/11/04/the-magical-island-of-kanren-core-logic-intro-part-1/以获取我想要运行的完整示例。)
(ns hw2.handler
(:use compojure.core)
(:refer-clojure :exclude [==])
(:use clojure.core.logic)
(:require [compojure.handler :as handler]
[compojure.route :as route]))
(defrel father Father Child)
lein 2.0生成的project.clj文件如下:
(defproject hw2 "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.5.1"]
[compojure "1.1.6"]
[org.clojure/core.logic "0.8.5"]
]
:plugins [[lein-ring "0.8.10"]]
:ring {:handler hw2.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]]}})
如果我运行lein ring服务器,我会得到:
ian@U11-VirtualBox:~/cljtest/test1/hw2$ lein ring server
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: defrel in this context, compiling:(hw2/handler.clj:21:1)
根据lein的说法,一切都是最新的,即:lein deps相应地下载所有内容等.O / S是Ubuntu 13。
从命令行:
ian@U11-VirtualBox:~/cljtest/test1/hw2$ lein repl
nREPL se rver started on port 47146 on host 127.0.0.1
REPL-y 0.3.0
Clojure 1.5.1
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (use 'clojure.core.logic)
WARNING: == already refers to: #'clojure.core/== in namespace: user, being replaced by: #'clojure.core.logic/==
nil
user=> (defrel father Father Child)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: defrel in this context, compiling:(/tmp/form-init6854269717866939932.clj:1:1)
再次运行*工作正常。
我尝试过http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html,但找不到有效的方法。
答案 0 :(得分:3)
From 0.8.4 to 0.8.5
====
Changes
----
* old defrel functionality now replaced by pldb