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

classes as assertions #3

Open
Anniepoo opened this issue Feb 20, 2019 · 2 comments
Open

classes as assertions #3

Anniepoo opened this issue Feb 20, 2019 · 2 comments

Comments

@Anniepoo
Copy link

This is a half formed thought as I'm headed to bed, putting it out for people to poke at.

One very common manipulation for js is to add and remove classes - and many status changes are best indicated that way.
Say I have an input field that's given a class when it's input isn't valid, something that has to be tested on the server.

The server pengine exposes invalid/1

option 1:

{|vue|| <input class="someclass @invalid(this.value)" ... />  |}

option 2:

{|vue|| input(class([someclass, @invalid('this.value')]), name(username), ...], [])  |}

Or, even sneakier -
a declarative

:- vuelog_class  invalid("this.value").

which means 'if you see invalid in the source html classes, make a pengine call and if it succeeds,
add the class invalid. The arguments to the call are the javascript expressions in the strings

lots of questions - is the class initially present? How does it decide to render?

But the core of the idea is that classes are predicates for html. Why not treat them as prolog predicates?

@Anniepoo
Copy link
Author

Anniepoo commented Feb 22, 2019

OK, more cogitating.

We can logically describe a part of the DOM as being conditional using implication and deontic logic.

% the myattribute attribute of everything with myclass must be myvalue when some_prolog_on_server
% is true.

.myclass["myattribute"] = X  :- 
    some_prolog_on_server.

// set the contents of mywarning 
#mywarning.innerhtml = "<p>dont do that!</p>" :- other_prolog_pred.

// set the contents of UL.mytodos to a list of the proofs of nondet_pred.
// if X is a solution to nondet_pred, tthen there exists an element of the dom whose
// innerhtml is X within UL.mytodos LI.atodo
UL.mytodos  LI.atodo = { innerhtml: X, margin: 0; } :- nondet_pred(X).

I wonder if this can be done with a quasiquote and the usual surrounding with deontic.

@Anniepoo
Copy link
Author

ok, may have worked out a way to make this computationally tractable over dinner tonight, but need to sleep on it. The napkin's in my purse.
Gist of it is codewalking and bumping the generation # of stateful things.

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

No branches or pull requests

1 participant