These are chat archives for jdubray/sam

9th
Dec 2016
Tarcio Saraiva
@tarciosaraiva
Dec 09 2016 06:04
hey @jdubray I've come across SAM a couple of weeks ago and have been trialling out on an open source project at the company I work for. I really enjoyed using it but am keen for some feedback. You will find the code here: https://github.com/DiUS/build-lights/tree/master/web-controller
You wll notice that the model lives in the server part of the code but I'm missing something like a UI model there as my choice of rendering engine (stateless components using Inferno) is forcing me into a path I don't like: using network events for UI operations. If I just stick with DOM manipulation then things get a bit messy with Inferno... anyway, that's that: UI model and server model, with the UI model being created as a transformation of the server model.
Thoughts? :)
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:17
@tarciosaraiva In general you don't need to duplicate the model or even the state function. SAM is fully isomorphic so you can move any combination of the actions/model/state function from the browser to the server. That being said, if the model runs on the server and the state function on the browser you would need to pass the model to the state function.
Did you take a look at the SAFE library? It could be of interest for the kinds of things you are building.
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:22
Your implementation sounds about right, though in general you would not pass the model to the view, but rather the transformation of the model into a state representation (via the state function).
In simple cases, model ~ state representation
devin ivy
@devinivy
Dec 09 2016 16:24
the model should be neat and orderly, containing no or very little duplicate information. or derived information.
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:24
You may want to look at meiosis too for trying different rendering strategies.
devin ivy
@devinivy
Dec 09 2016 16:24
then your app state can be complicated, derived, denormalized
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:24
@devinivy :thumbsup:
exactly, it would make it easy(ier) to render the view without putting too much constraints on the model
devin ivy
@devinivy
Dec 09 2016 16:26
yeah. when our team got used to this, things got easier.
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:27
you are using SAM?
devin ivy
@devinivy
Dec 09 2016 16:28
not exactly, no. but definitely borrowing ideas from SAM. this is just for work. outside of work i have used SAM
for example, we don't have nap()
but we have pushed validation into the model
and are serious about state (versus model)
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:29
really cool!
devin ivy
@devinivy
Dec 09 2016 16:29
yes! thank you :)
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:30
@edmulraney The definition you have is pretty close, it would require to define "prime" variables. Did you check Dr Lamport's book on TLA+ http://research.microsoft.com/en-us/um/people/lamport/tla/book-02-08-08.pdf
blob
that's page 34
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:35
my interpretation is that an action in SAM is a function that computes a proposal (prime variables) for the model
Edward Mulraney
@edmulraney
Dec 09 2016 16:37
what does "An action is true or false of a step" mean?
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:37
The equivalent of the model is the next-state function
It's because the next-state function is organized in predicates connected with logical operators (^ v)
the important aspect is the computation of prime variables from non prime (and prime) values
Also, an action does not cover the entirety of the model
For instance things like "the de finition of an action usually begins with its enabling condition" are related to the way the temporal logic is expressed.
Edward Mulraney
@edmulraney
Dec 09 2016 16:44
I don't understand what the relevance true/false has to an action/step
what is it that is true or false?
"An action is true or false of a predicate" makes more sense?
or, a predicate can initiate an action?
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:47
As I understand it, TLA+ is used to express specifications of a system from an initial state to a terminal state. It is not a program in the sense that you and I are writing. It is rather all the possible paths of the program.
blob
This is the specification of an hour clock
if hr = 15, the system cannot start
the clock action here would always be true (?)
IMHO, this return value is part of the wiring of the specification
Jean-Jacques Dubray
@jdubray
Dec 09 2016 16:56
The specification will allow you to explore all possible paths of the system
Jean-Jacques Dubray
@jdubray
Dec 09 2016 17:10
Here is a more substantial spec
blob
You can see that the logical operators are used as composition mechanisms, it does not seem that the return value is materials to the programming model (again, IMHO)
Jean-Jacques Dubray
@jdubray
Dec 09 2016 17:22
This is how Action and Model (aka State function in TLA+) are connected in the specification
blob