This is a nice question I kept asking myself.
I came to the conclusion that it is best to keep your model and your update function as simple as possible.
In the model, there shouldn't be more than one representation of the same datum.
The calculations should be made inside the view function, unless you encounter performance issues.
Here are two reasons:
- This way, I understand the program better. When I look at an elm-program, I first look at the model. So the model should be comprehensible. If you have two different representations of the same datum, I think you should write a comment and make that clear that it is for performance reasons. Performance should be the only reason for breaking this rule. As long as you don't encounter performance problems, keep the model simple, even if this makes you calculate things more than once.
- It also prevents bugs because if you have two fields holding different representations of the same thing, every time you update one field you also should update the other. Sometimes, you forget that and then you lose your time to find out where you made the mistake.