I have two elm modules trying to share a union type as I try to refactor my app as described here https://www.elm-tutorial.org/en-v01/02-elm-arch/07-composing-2.html but I keep getting
does not expose
even though I have tried to model it as in https://github.com/elm/elm-lang.org/issues/523
Module 1
module Module1 exposing ( OneMsg(..), Model, view, [etc.] )
...
type OneMsg
= Name String
...
Module 2
module Module2 exposing(..)
import Module1 exposing(OneMsg(..))
type Msg
= UrlChange Navigation.Location
| ...
| Module1Msg Module1.OneMsg
...
Html.map Module1.OneMsg (Module1.view model)
...
Getting this error
-- NAMING ERROR ---------------------------------------------- ././view/View.elm
Cannot find variable `Module1.OneMsg`.
74| Html.map Module1.OneMsg (Module1.view model)
^^^^^^^^^^^^^^^^^^
`Module1` does not expose `OneMsg`.
Only thing I found here is an old questions which seems to be the same event though an old syntax: Access Union Types outside of declaring module in Elm
In case relevant I use elm 0.18.0.
Bet I just missed something. Can any one spot the problem?
Module1.OneMsg
is a type. Html.map
expects a function as its first parameter. The way you typically bubble up messages would be something like this (in Module2
):
type Module2Msg
= ...
| Module1Msg Module1.OneMsg
And then you could use it like this in Module2
:
Html.map Module1Msg (Module1.view model)