I have this demo code, where I have a record in my model, which represents my domain object, which again contains a list of records of a related domain object (
Template, which contains a list of
Group). I’ve tried to create my messages for updating these records from these design goals:
- I want my messages to clearly signal when they make sense to send and receive (my current design does this by nesting messages, since you can’t update a
Groupin the UI without updating the
Templatethe group resides in)
- The user can add an arbitrary number of
Groups to a template, so I need messages to specify the exact group that is being updated (which I’ve done by putting the index of the group in the message)
I have two questions for this:
1: Am I going about this in a sensible way, or is there a more idiomatic way to do it?
2: This way of organizing
Msgs would work quite nicely with currying, but it seems like I’m missing a way to do currying with types only; my workaround is putting it in a function ala:
viewGroupEditor : Int -> Group -> Html Msg viewGroupEditor index group = div  [ input [placeholder "Group Name", value group.name, onInput (groupNameMsg index) ]  ] groupNameMsg : Int -> String -> Msg groupNameMsg index input = UpdateTemplate (EditGroup index (UpdateGroupName input))
Is there a way to do currying just with types?