سؤال

I'm having trouble getting clojure to recognise defrel from the core.logic libraries. So after setting a project up with lein (and compojure) and getting core.logic run* to work, I tried a simple example using defrel...below is the generated header including the :use clojure.core.logic and the line that fails (see http://objectcommando.com/blog/2011/11/04/the-magical-island-of-kanren-core-logic-intro-part-1/ for the full example I'd like to run).

    (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)

The project.clj file generated by lein 2.0 is below:

    (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"]]}})

If I run lein ring server I get:

    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)

According to lein, everything is up to date, ie: lein deps downloads everything accordingly etc. O/S is Ubuntu 13.

From the command line:

    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) 

Again run* works fine.

I've tried working through http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html but I can't find anything that works.

هل كانت مفيدة؟

المحلول

Changelog :

From 0.8.4 to 0.8.5
====

Changes
----
* old defrel functionality now replaced by pldb
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top