Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate highlighting Precept syntax directly #26

Open
alex-dixon opened this issue Apr 28, 2018 · 0 comments
Open

Investigate highlighting Precept syntax directly #26

alex-dixon opened this issue Apr 28, 2018 · 0 comments

Comments

@alex-dixon
Copy link
Contributor

Somewhat related to #13.

The problems:

  1. the entities macro and defsub expand to multiple rules. For a subscription rule this means we show something like the following:

Conditions:

[[?54076 :precept.spec.rulegen/for-rule (= task-list-sub___impl (:v this))]]
[[?54076 :precept.spec.rulegen/for-macro (= :precept.spec.rulegen/entities (:v this))]]
[[?54076 :precept.spec.rulegen/request-params ?eids]]
[[?54076 :precept.spec.rulegen/response ?visible-todos]]
[[_ :active-count ?active-count]]

Matches:

[8b4f0908 :precept.spec.rulegen/for-rule {:name todomvc.rules/task-list-sub___impl,
 :ns-name todomvc.rules,
 :lhs [{:constraints [(= ?e___sub___impl (:e this))
                      (= :task-list (:v this))],
        :type :precept.spec.sub/request}
       {:constraints [(= ?54076 (:e this))
                      (= task-list-sub___impl (:v this))],
        :type :precept.spec.rulegen/for-rule}
       {:constraints [(= ?54076 (:e this))
                      (= :precept.spec.rulegen/entities
                       (:v this))],
        :type :precept.spec.rulegen/for-macro}
       {:constraints [(= ?54076 (:e this)) (= ?eids (:v this))],
        :type :precept.spec.rulegen/request-params}
       {:constraints [(= ?54076 (:e this))
                      (= ?visible-todos (:v this))],
        :type :precept.spec.rulegen/response}
       {:constraints [(= ?active-count (:v this))],
        :type :active-count}],
 :rhs (do (do (do (precept.util/insert!
                   [?e___sub___impl :precept.spec.sub/response
                    {:visible-todos ?visible-todos,
                     :all-complete? (= 0 ?active-count)}])))),
 :props {:group :report}}]
[8b4f0908 :precept.spec.rulegen/for-macro :precept.spec.rulegen/entities]
[8b4f0908 :precept.spec.rulegen/request-params (#uuid "1d539fb5-3a69-43f3-a972-f0a7714adf64"
 #uuid "7884fcda-95fe-4c3d-b75d-294f0bfaa4c4")]
[8b4f0908 :precept.spec.rulegen/response ([[1d539fb5 :todo/title Hi] [1d539fb5 :todo/done false]
  [1d539fb5 :todo/visible true]]
 [[7884fcda :todo/title there!] [7884fcda :todo/done false]
  [7884fcda :todo/visible true]])]
[:global :active-count 2]

Consequence:

{:visible-todos ([[1d539fb5 :todo/title Hi] [1d539fb5 :todo/done false]
  [1d539fb5 :todo/visible true]]
 [[7884fcda :todo/title there!] [7884fcda :todo/done false]
  [7884fcda :todo/visible true]]):all-complete? false}

We show this in the rules view, which is the literal syntax the user wrote (it comes from a different source than the condtition/match/consequence parsing code):

;; task-list-sub___impl___impl_split-0
(defsub :task-list
[?eids <- (acc/by-fact-id :e) :from
[:todo/visible]]
[(<- ?visible-todos (entities ?eids))]
[[_ :active-count ?active-count]]
=>
{:visible-todos ?visible-todos, :all-complete? (= 0 ?active-count)})

This is a pretty complex example, because entities is being used in defsub, hence sub-__impl (rewrites the sub with :sub-request/task-list for its first condition) and __impl_split-0 (defines two new rules -- a generated one that inserts, and a rewritten original that has conditions that match on the result of it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant