This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-02
Channels
- # announcements (2)
- # beginners (69)
- # boot (1)
- # cider (35)
- # clara (1)
- # cljs-dev (1)
- # clojure (40)
- # clojure-spec (11)
- # clojure-uk (8)
- # clojurescript (9)
- # cursive (1)
- # datomic (5)
- # figwheel-main (25)
- # fulcro (64)
- # jobs (2)
- # jukebox (1)
- # kaocha (3)
- # off-topic (7)
- # pathom (39)
- # planck (5)
- # random (1)
- # re-frame (11)
- # reagent (8)
- # shadow-cljs (58)
- # test-check (41)
- # vim (13)
Hello everyone, I have a problem with clara rules and I hope you can help me. To resolve components that are productive I create facts of dependencies and mark components that are used by productive components as productive as well. Right when I have a loop in the dependency chain, clara rules ends up in a endless loop while firing rules. Here is the code:
(ns clara.error
(:require [clara.rules :refer :all]))
(defrecord DependsOn [element dep])
(defrecord Productive [element])
(defrule productive
""
[DependsOn (= ?element1 element) (= ?element2 dep)]
[Productive (= ?element1 element)]
=>
(insert! (->Productive ?element2)))
; Works
(as-> (mk-session 'clara.error) $
(apply insert $ [(->Productive "A")])
(apply insert $ [(->DependsOn "A" "B")
(->DependsOn "B" "C")
(->DependsOn "C" "D")])
(fire-rules $))
; ends in a loop
(as-> (mk-session 'clara.error) $
(apply insert $ [(->Productive "A")])
(apply insert $ [(->DependsOn "A" "B")
(->DependsOn "B" "C")
(->DependsOn "C" "A")])
(fire-rules $))
The approach of clara rules is awesome. That's why I hope we can find the problem so I can continue using clara rules.
Thanks in advance.