Hi Mark. I think you’re right that the Time.every

Here is Evan saying “don’t put functions in the model (or messages)”:

But the position has a lot of follow on effects that haven’t really been addressed or considered. It means you shouldn’t store subscriptions in your model for easy return. It means that animation libraries shouldn’t allow client supplied interpolation functions. It basically throws out a lot of something that is considered central to a lot of other functional programming which is modeling things with functions.

So, we have to ask what are the benefits of avoiding functions in models and messages. Functions can’t be serialized so their use inhibits the recording logic in the Elm debugger. Do you care? My team has looked at it and not seen where the debugger would really help any problems we’ve had so far. You may have a different experience. Functions can’t be compared for equality — and the compiler won’t tell you this — so not putting functions in the model can help prevent a lurking runtime crash. But I’ve ended up just staying away from equality comparisons because functions slip in via core types like subscriptions. Functions are hard to introspect, so I would stay away from them in any places where one might need to look more deeply to debug a problem, but that’s more about being cautious about where functions appear than it is about avoiding them entirely.

Finally, I’ve found it useful to try to structure the side of our app that talks to the server much as if it were an effects manager. We’ve thought about just writing it as an effects manager but doing so interferes with using other effects managers and effects managers are barely documented and what documentation there is says essentially don’t write them. So, basically, we’re building the “user mode” equivalent of an effects manager and doing so is going to require storing functions just as effects managers do.

Use your best judgment but be prepared to hear from the hard core believers that you are doing it wrong — though in this particular example, they probably aren’t even thinking about the fact that storing a subscription means storing a function.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.