Hey @xilnocas,
I appreciate how much time you put in your post, as well as all of the thoughtful comments.
Just my two cents having spent the last 6 months building out a fairly large Elm app (15,000+ LOC).
From a high level, I think you are going to regret it if you start to build a large Elm app and do what you are proposing.
Even the very first concept leads down a very dark path. The idea that you would immediately split out an elm app along the lines you propose will likely lead to much pain and suffering.
I’m not a big poster online, but think you may find this useful:
(My re-write of elm-taco, another proposal for scaling Elm apps. I have never posted a link to it before.)
I just say this from recently bringing on developers who are joyful at how easy it is to add new code and understand what is going on with our fairly complex codebase. We follow elm-taco-donut
exactly, and it worked (and works!) like a charm.
As soon as you start getting stuff like:
view : Model -> (Msgs -> View -> Html msg) -> Html msg
you are going to be unhappy.
All our views are
view : Model -> Html Msg
(including Modals, Overlays, Alerts, Pages, etc.)
Super simple. Update the model, and the views change! Voila!
I would just feel bad for someone to stumble across your well-meaning post and think that this was a “good” way to build Elm apps.
You will be fighting TEA the whole way.
Personally, I think one of the hardest problems people have with Elm is that they get scared of big files. Because in other languages, big files lead to big problems. So there is an urge to chop up files into “components/bits/whatever”.
Unfortunately, this often fights the very nature of Elm’s central message bus, and of Elm’s idea of a central Model.
The fact that you create a new thing called State
should be a hint that maybe this is a dark road indeed! Model
is the state. That’s the whole point. The model can be as big are you like, with as many Lists, Records, Dicts, etc as you need. There is no benefit to breaking it up, and many reasons not to.
Also, there should only be one thing parsing update messages. That’s the point of TEA. That’s what keeps it sane.
Anyway, sorry for the blunt feedback. I rarely post online, but this an area of much personal experience.
My comments are purely practical, and I apologize in advance if they are unwelcome.
Rock on,