Hey folks. Really cool lib!
I posted this in #clara but probably of interest here: >>> Maybe something like this (in tuple / #precept syntax instead of default Clara):
(def-tuple-rule ready-exit-missing-password
[[:app :state :login]]
[[:login :state :ready]]
[[_ :missing-email]]
=>
(insert-unconditional! [[:login :state :password-error]]))
a macro would expand the concise statechart syntax to rules like that.
and then of course you could define/derive :missing-email
elsewhere (edited)
@jfntn do I have what you're thinking right?that's in response to asking how one could handle statecharts in the form
(def app-statechart
{'Visitor
{:login
{'LoginForm
{'Start {:init 'Ready}
'Ready {:missing-password 'Password-Error
:missing-email 'Email-Error
:submit 'Submitting}
'Password-Error {:change-password 'Ready}
'Email-Error {:change-email 'Ready}
'Submitting {:receive-success 'Success}}}
:signup {... }}
'User {...}
'Admin {...}})
@john thanks!
My initial question from the docs was "why do I have to pass a whole namespace to session
?" But I see that the rules namespace is being populated by macros.
Seems like a wart that would be worth smoothing over if it was possible, but I'm not sure if it's possible. I heard y'all were looking for feedback, so that's all I got 🙂 Super excited about the idea!
@mikegai thanks for the explanation, I think I’m starting to see how this’d work. I haven’t played with clara or precept yet so I’m not clear on the syntax, would you please correct me: - the first tuple asserts the :app singleton’s :state property is :login (parent guard) - the second asserts that the :login state is :ready (node/child guard) - the third asserts any transition to :missing-email. Finally the rhs transitions the node/child state to :password-error?
When app state is login and login state is ready and there is a missing email, then login state is password error
@jfntn sorry best I can do on my phone :)
Gotcha, thanks
To clarify, I'd restate it as "then change login state to password error" instead of "then login state is password error". insert!
means "so long as the condition is true, then the consequence is the case" (because it will be auto-retracted if the conditions go false, making it a sort of definition) while insert-unconditional!
means "change/mutate"