Open francois opened 4 years ago
I ran into this yesterday working with a co-worker who's new to Elm. Another couple aspects of this error that make it hard for beginners to troubleshoot are:
Msg
if I have msg
aka: where to apply a toMsg : Msg -> msg
function usually in some view
code...msg -> Msg
or Msg -> msg
and WHY.In our case the idea was to rip some code from another part of the app, stitch it into a different context and make the minimal amount of changes to have something rendering on the screen (regardless of whether or not the behavior was correct)...
The more nefarious issue is what I call Top-Down vs Bottom-Up in Elm.... where
Issue in Bottom-Up is specifically WHICH types to change... eg: do we change the type of the implementation so it fits in it's context (which may or may not be possible depending on parent-child relationships between Msg's) or do we change the types of the context to satisfy the more general type of the child.
The whole premise of "Parent Child" relationships between Sum types in Elm seems to be the root of a significant deal of confusion, even amongst experienced Elm devs.
I know other "UI" focused language design communities offer a number of other organizational primitives like Streaming api's ala: rxjs / SolidJS ... OR Monadic DSL's vs Applicative DSL's ala: https://github.com/janestreet/bonsai/blob/761d04847d5f947318b64c0a46dffa17ad413536/docs/blogs/why_no_bind.md
And there's other ideas in the wild I've stumbled on but who's implementations don't have NEARLY the community backing that the Elm architecture has built up over the years.
QUESTION: I wonder if there's either One: an answer to the "which direction do I need to fix the types in?" or I suppose more philosophically relevant, is there a better "Parent Child" model we can leverage for helping Beginners understand how to model programs?
Over on Beginner thought process on type mismatch error, I described how I had difficulty understanding a Type Mismatch error:
lydell explained the message thusly:
The self-contained example is: