These are chat archives for jdubray/sam

20th
Dec 2016
Jean-Jacques Dubray
@jdubray
Dec 20 2016 00:44
@edmulraney perhaps, but ultimately you have to reflect back and say was that the right decision? I'd argue not, but I am obviously biased.
All I am saying is that when you look at the Elm/Redux architecture
blob
The semantics of that big red box are too open
I just suggest adding a bit more structure. SAM structure is as follows
blob
I don't think we gain much by keeping it that open. If you find a better model, so be it, I am not here to win a prize, but I'd argue we'll see the same kind of mess that we got with MVC, perhaps even greater because that box is now a pure function.
Jean-Jacques Dubray
@jdubray
Dec 20 2016 00:49
People even start claiming that this is actually MVC, the red box being the controller.
Edward Mulraney
@edmulraney
Dec 20 2016 07:35
i havent played with elm yet but looking at your Counter example, the model.present is implicit in the update function, but you still have access to the model so its fully capable of rejecting/accepting
before performing the mutation
Edward Mulraney
@edmulraney
Dec 20 2016 07:46
what really is the crux of model.present? to force validation of an action before the action effect (mutation) is applied? ive been looking into TLA+ and think the hour clock is a good example
in the hour clock example, a safety predicate would be set up to check that if the current hour doesnt equal 12: then increment it, otherwise return the first hour: 0
Jean-Jacques Dubray
@jdubray
Dec 20 2016 14:21
Exactly, the action is "tick" the model then decide how the system responds to a tick. The separation Action/Model provides a boundary that isolates the system (model) from knowledge of the outside. Let's take the example of leap seconds. Incidentally both the American and the French question why we have to align time so precisely with the revolution of the Earth around the Sun, and you guess it, the Brits are for that alignment (are you guys still navigating with Sextants?). But I degress, what would be the best way to implement the leap second? an action or the model? The model should implement the clock, translating ticks into a readable time. The clock should know nothing about how the ticks are generated (from grain of sands to quartz vibrations). Should the clock know anything about leap seconds? probably not, a sensible implementation would be an action that receives a tick event, queries the current position of the earth and decides to increment by two, one or zero depending if the clock is ahead, at or behind the expected position of the earth.
In Elm or standard Redux that separation is not possible. Model and Action are coupled.
Edward Mulraney
@edmulraney
Dec 20 2016 16:13
your assumption about redux isn't right. you can have a root reducer which has access to the entire state, or you can place your logic in a thunk action, which also has access to entire state
devin ivy
@devinivy
Dec 20 2016 16:22
though i think @jdubray talks more about common redux paradigms/usages. he's acknowledged that redux and SAM are compatible.
Edward Mulraney
@edmulraney
Dec 20 2016 16:24
it's true they are. which is why i was surprised by this: "In Elm or standard Redux that separation is not possible. Model and Action are coupled." i'm not sure what that coupling is
devin ivy
@devinivy
Dec 20 2016 16:42
i think model and action are coupled when an action is always "one tick" of the application. in the case of something like debouncing an action's effect on the model, a single action cannot be that tick.
devin ivy
@devinivy
Dec 20 2016 16:49
that's where propose() has a non-trivial implementation, i believe. in redux this might be akin to middlewares.