Comments (5)
Each template has its own rule (I abusely use rule for idb predicate) and this rule has as many arguments as there are lexical bindings.
A template rule must use its parent rule.
I feel there's a need for a path attribute (that would mean a constructor -- skolem predicate)
from enlivez.
Some things are counterintuitive at first: name and arguments of a deftemplate are an IDB predicate and each call site to a template is in fact a derivation rule for its predicate!
from enlivez.
Trying to recap: each "template" is associated to a rule whose last argument is a path.
Assuming only x
is bound so far, (x/for (and (a x y) (b y z)) body)
produces:
for_q_1234(x, y, z) :- a(x, y), b(y, z).
for_body_activation_1234(x, y, z, path) :- for_activation_1234(x, p), for_q_1234(x, y, z), vector(y, z, v), conj(p, v, path).
active_components(path) :- for_body_activation_1234(x, y, z, path).
A fragment (body) with N sub templates would produce:
subtemplate1_activation(bound-vars..., path) :- fragment_activation(bound-vars..., p), conj(p, 1, path).
...
subtemplateN_activation(bound-vars..., path) :- fragment_activation(bound-vars..., p), conj(p, N, path).
active_components(path) :- subtemplate1_activation(bound-vars..., path).
...
active_components(path) :- subtemplateN_activation(bound-vars..., path).
A terminal doesn't create rules on its own : its just a terminal, it consumes data from its activation.
Last but not least, a deftemplate creates a public activation rule and each "call" to a template is going to add rules to this activation.
from enlivez.
Addenda:
- it's easier to have the path as the first argument (and it doesn't matter as it's an implementation detail).
- terminals do emits rules:
active_components(path) :- terminal_activation(p, bound_vars...), vector(used_vars, v), conj(p, v, path)
from enlivez.
Things are starting to fall in place again. Phew.
Fragments and terminals are correctly emitting their rules. For example
=> (ez/deftemplate xoxo [] (for [(_ :user/name name)] [:h1 "hello" name]))
=> (`ez/component-path (impl/eval-rules {`xoxo #{[[] "You"]}} (ez/collect-rules xoxo)))
#{([0 ["You"]])}
for
is in progress (i.e. being actively debugged).
(Note to self: deps are not collected now, they should.)
To give some background: in the 1st prototype, components paths were computed by running many complex and wide queries and then mapping result sets to create paths.
Not only this was inefficient because these big queries were sharing a lot of subqueries (so duplicated execution) but it was also hacky (in the way queries were built) and, more concerning, it was hindering expressivity in two ways:
- no possibility to call rules (plus rules restrictions in datascript/datomic disallow one to use 2+ datasources which is a problem)
- no possibility to have recursive templates (that is to render trees) because the hack to generate queries would mean to produce an infinity of queries.... unless you can use rules (GOTO 1).
As of today I had the first components paths computed by rules (interpreted by the nascent EZ datalog impl). It means that soon I'll be able to plug back components instantiation on it.
from enlivez.
Related Issues (20)
- Day #10
- Day #11
- Day #12 and #13
- Day #14 HOT 2
- TODOs HOT 1
- Days #15 #16 #17
- Unstub derivatives
- Unstub DOM
- Clean for-component
- Allow expressions in sort key HOT 1
- Less awkward predicates HOT 1
- `:state` maps shouldn't be query maps HOT 2
- Is `:state` needed at all?
- Recursive templates HOT 4
- Collapsing empty sections
- aggregations
- lifting ors HOT 3
- Relational expressions HOT 2
- Handlers and activations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enlivez.