Skip to content

Commit cf3c90d

Browse files
committed
Update core.logic dependency
Updates to core.logic 0.8.10 + patch for LOGIC-168
1 parent b2a2228 commit cf3c90d

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

project.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
:license {:name "Eclipse Public License"
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
66
:scm {:url "[email protected]:palletops/locos.git"}
7-
:dependencies [[org.clojure/core.logic "0.8.0-beta3"]
7+
:dependencies [[org.hugoduncan/core.logic "0.8.11-SNAPSHOT"]
88
[org.clojure/tools.logging "0.1.2"]
9-
[org.clojure/clojure "1.4.0"]])
9+
[org.clojure/clojure "1.6.0"]])

src/palletops/locos.clj

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
(ns palletops.locos
22
"Allow use of declarative rules for specifying configuration options"
33
(:refer-clojure :exclude [==])
4-
(:use
4+
(:require
55
[clojure.core.logic
6-
:only [all defc fresh membero partial-map prep project run* s# walk-term
7-
== >fd <fd]]
8-
[clojure.tools.logging :only [debugf warnf]]
9-
[clojure.walk :only [postwalk]]))
6+
:refer [all defnc featurec partial-map fresh membero project run* s# ==]]
7+
[clojure.core.logic.fd :as fd]
8+
[clojure.core.logic.protocols :refer [walk-term]]
9+
[clojure.core.logic.unifier :refer [prep]]
10+
[clojure.tools.logging :refer [debugf tracef warnf]]
11+
[clojure.walk :refer [postwalk]]))
1012

1113
(defn deep-merge
1214
"Recursively merge maps."
@@ -45,19 +47,14 @@
4547

4648
(def ^{:private true :doc "Translate to logic functions"}
4749
op-map
48-
{`> >fd
49-
`< <fd
50-
'> >fd
51-
'< <fd})
50+
{`> fd/>
51+
`< fd/<
52+
'> fd/>
53+
'< fd/<})
5254

5355
(defn ->pmap
5456
"Return a value that will use partial-map unification"
55-
[x]
56-
(if (and (map? x)
57-
(not (instance? clojure.lang.IRecord x))
58-
(not (instance? clojure.core.logic.PMap x)))
59-
(partial-map x)
60-
x))
57+
[x] x)
6158

6259
(defn recursive-partial-map
6360
"Return a value that will use partial-map unification on sub-maps"
@@ -70,7 +67,7 @@
7067
[rule]
7168
(let [[pattern production & guards] (prep rule)]
7269
{:rule (or (-> rule meta :name) (first rule))
73-
:pattern (recursive-partial-map pattern)
70+
:pattern (->pmap pattern)
7471
:production production
7572
:guards (fn []
7673
(if (seq guards)
@@ -132,22 +129,23 @@
132129
`(def ~name (rules->logic-terms ~(vec (quote-rules rules)))))
133130

134131
;; guarantee that a path of keys does not occur in map x
135-
(defc not-pathc [x path]
132+
(defnc not-pathc [x path]
136133
(= (get-in x path ::not-found) ::not-found))
137134

138-
(defc get-c [x s]
135+
(defnc get-c [x s]
139136
(not= (get s x ::not-found) ::not-found))
140137

141138
(defn matching-productions
142139
"Takes an expression, and applies rules to it, returning a sequence
143140
of valid productions."
144141
[expr rules]
142+
(tracef "matching-productions" expr rules)
145143
(run* [q]
146144
(fresh [pattern production guards rule]
147145
(membero
148146
{:pattern pattern :production production :guards guards :rule rule}
149147
rules)
150-
(== expr pattern)
148+
(featurec expr pattern)
151149
(== q {:production production :rule rule})
152150
(project [guards] (guards)))))
153151

@@ -156,6 +154,7 @@
156154
[expr rules]
157155
(if-let [productions (seq (matching-productions expr rules))]
158156
(do
157+
(tracef "productions" productions)
159158
(when-let [invalid (seq (remove map? productions))]
160159
(warnf "Skipping locos productions %s" (vec invalid)))
161160
(reduce

0 commit comments

Comments
 (0)