Sure!
At least in Elm 0.18, SPA routing between pages is by far the most common use case. (I expect that in a future release, code splitting will result in an alternative API for doing this, but Html.map
seems to be the right approach for today.)
The other two modules (besides Main
) that use Html.map
are Home
and Profile
. Both of them use it for Feed
.
The reason I used it for Feed
is that Feed
has 6 Msg
values and their update
logic is nontrivial.
I default to not creating Feed.Msg
and Feed.update
, because they’re usually not worth the cost, but this is one of the rare cases where the alternative would be worse! In the alternative world, Feed.view
would have to accept 6 different toMsg
functions, every page that used a Feed
would be required to add 6 constructors to its own Msg
, and the corresponding update
clauses would have to call ~6 different Feed
functions because their implementations are nontrivial.
Because of the high Msg
count and nontrivial update
logic that goes with them, in this case—unlike every other case in the app—the comparatively lightweight approach was to use Feed.Msg
and Feed.update
…even though everywhere else in the project, a view
function alone was the better API.