About the "How do I generate a new message as a command?" answer
jvoigtlaender opened this issue · comments
The answer currently says "This is not recommended to do; it’s an anti-pattern."
Is there some source for this, explaining why it is an anti-pattern? For example, a mailing list thread or so.
Also, aren't there situations where it's really the right choice to go that way? For example, this on the mailing list. Going with recursively calling the update function does not seem a better solution there.
In any case, even if aiming to discourage this pattern, I think the answer could give better expressions for when one really wants to apply it. Instead of
Task.perform (\_ -> (Debug.crash "fail")) (always Test) (Task.succeed ())
and
Task.perform (\_ -> Test) (\_ -> Test) (Task.succeed ())
why not
Task.perform (\_ -> (Debug.crash "fail")) identity (Task.succeed Test)
and/or the following?
Task.perform identity identity (Task.succeed Test)
One could also point out performFailproof
from http://package.elm-lang.org/packages/NoRedInk/elm-task-extra.
But in any case, making the solution artifically horrendous seems a bit ideological. 😄
Perhaps that item is too opinionated, as you say. The "anti-pattern" bit came from a Slack thread and so there is not a good long-term reference available. The "horror" bit is my doing and should go. The code examples were the consensus at the time. I think yours are better.
I'll rework that item along the lines of this discussion.
Thanks!