DEV Community


Discussion on: PureScript: UI driven by Finite State Machines and Event Streams

dimsuz profile image

A follow-up question. You say:

In Elm, every update function returns Cmd along with the model, which is also the wrapper for the effects, still you may need some effort to realise it. Actually, they separate model from the effects, and that’s smart thing to do, so let’s do the same.

But why is this the smart thing to do here? What do can we get from it, what benefits will it bring compared to simply returning "Effect model"? Will it help in testing/mocking somehow or are there any other gains?

shamansir profile image
Ulric Wilfred Author

I hope a late reply still counts.

Effect model in contrast to Effect (List action) is completely hiding the things one does with the model during the Effect process, so it is much harder to tell and debug what happened there. So yes, it will help in testing as well. When the list of actions to perform is returned and the update is granular or atomic, so any action makes only a subtle indivisible change to a model, then anything what happened is trackable.

This concept was also praised in Redux and with the useEffect in React — it is easier to track actions if they are as minimal, indivisible and descriptive as possible.

Plus, it gives you the way to rollback the effects one by one and implement the Redo/Undo in just few easy steps.

Thread Thread
dimsuz profile image

Thank you!

Forem Open with the Forem app