Starting from those three declarations :
type SharedMsg
= SharedAction
type Page1Msg
= Page1Action
type Page2Msg
= Page2Action
I there a way to obtain an equivalent of the following one? Like a way to "merge" union types ?
type Msg
= SharedAction
| Page1Action
| Page2Action
=============================
Context : I am splitting an Elm application into one module per page with their own folders.
Some actions will be shared, and some actions will be page-specific.
If I was to use the Html.map
method, I feel that I would have to re-write every shared action that a page uses in its own PageMsg
message type:
type Page1Msg
= Page1Action
| SharedAction
type Msg
= Page1Msg Page1Msg
| Page2Msg Page2Msg
view : Model -> Html Msg
view =
Html.map Page1Msg (Page1View.view model)
Hence my thinking of using a unique Msg
type for all pages, but preserving modularity by writing page-specific messages in their own folders, and then somehow defining a unique Msg
type by merging them.