elm-spa
elm-spa copied to clipboard
exposesMsg works for Msg and Msg(..) but fails for Msg (..)
exposesMsg at https://github.com/ryannhg/elm-spa/blob/main/src/cli/src/templates/utils.ts#L330 detects Msg and Msg(..) but not Msg (..)
The latter goes obviously against elm-format, but is nevertheless valid syntax. Anyway, this causes elm-spa to slap a Never into Gen.Msg and the whole thing combusts spontaneously with a relatively complicated error message that may traumatize a junior developer for a long time. :-)
-- TYPE MISMATCH ------------------ .elm-spa/generated/Gen/Pages.elm
Something is off with the body of the `pages` definition:
138|> { home_ = static Pages.Home_.view Model.Home_
139|> , login = bundle Pages.Login.page Model.Login Msg.Login
140|> , customer__customer_ = bundle Pages.Customer.Customer_.page Model.Customer__Customer_ Msg.Customer__Customer_
141|> , customer__customer___devices = static Pages.Customer.Customer_.Devices.view Model.Customer__Customer___Devices
142|> , customer__customer___device__device_ = bundle Pages.Customer.Customer_.Device.Device_.page Model.Customer__Customer___Device__Device_ Msg.Customer__Customer___Device__Device_
143|> , notFound = static Pages.NotFound.view Model.NotFound
144|> }
The body is a record of type:
{ customer__customer_ :
ElmSpa.Page.Bundle
Gen.Params.Customer.Customer_.Params
Pages.Customer.Customer_.Model
Pages.Customer.Customer_.Msg
Shared.Model
(Effect Msg)
Model.Model
Msg
(View Msg)
, customer__customer___device__device_ :
ElmSpa.Page.Bundle
Gen.Params.Customer.Customer_.Device.Device_.Params
Pages.Customer.Customer_.Device.Device_.Model
Pages.Customer.Customer_.Device.Device_.Msg
Shared.Model
(Effect Msg)
Model.Model
Msg.Msg
(View Msg)
, customer__customer___devices :
Static Gen.Params.Customer.Customer_.Devices.Params
, home_ : Static Gen.Params.Home_.Params
, login :
ElmSpa.Page.Bundle
Gen.Params.Login.Params
Pages.Login.Model
Pages.Login.Msg
Shared.Model
(Effect Msg)
Model.Model
Msg.Msg
(View Msg)
, notFound : Static Gen.Params.NotFound.Params
}
But the type annotation on `pages` says it should be:
{ customer__customer_ :
{ init :
Gen.Params.Customer.Customer_.Params
-> Shared.Model
-> Url
-> Key
-> ( Model, Effect Msg )
, subscriptions :
Gen.Params.Customer.Customer_.Params
-> ()
-> Shared.Model
-> Url
-> Key
-> Sub Msg
, update :
Gen.Params.Customer.Customer_.Params
-> Never
-> ()
-> Shared.Model
-> Url
-> Key
-> ( Model, Effect Msg )
, view :
Gen.Params.Customer.Customer_.Params
-> ()
-> Shared.Model
-> Url
-> Key
-> View Msg
}
, customer__customer___device__device_ :
{ init :
Gen.Params.Customer.Customer_.Device.Device_.Params
-> Shared.Model
-> Url
-> Key
-> ( Model, Effect Msg )
, subscriptions :
Gen.Params.Customer.Customer_.Device.Device_.Params
-> Pages.Customer.Customer_.Device.Device_.Model
-> Shared.Model
-> Url
-> Key
-> Sub Msg
, update :
Gen.Params.Customer.Customer_.Device.Device_.Params
-> Pages.Customer.Customer_.Device.Device_.Msg
-> Pages.Customer.Customer_.Device.Device_.Model
-> Shared.Model
-> Url
-> Key
-> ( Model, Effect Msg )
, view :
Gen.Params.Customer.Customer_.Device.Device_.Params
-> Pages.Customer.Customer_.Device.Device_.Model
-> Shared.Model
-> Url
-> Key
-> View Msg
}
, customer__customer___devices :
Static Gen.Params.Customer.Customer_.Devices.Params
, home_ : Static Gen.Params.Home_.Params
, login :
{ init :
Gen.Params.Login.Params
-> Shared.Model
-> Url
-> Key
-> ( Model, Effect Msg )
, subscriptions :
Gen.Params.Login.Params
-> Pages.Login.Model
-> Shared.Model
-> Url
-> Key
-> Sub Msg
, update :
Gen.Params.Login.Params
-> Pages.Login.Msg
-> Pages.Login.Model
-> Shared.Model
-> Url
-> Key
-> ( Model, Effect Msg )
, view :
Gen.Params.Login.Params
-> Pages.Login.Model
-> Shared.Model
-> Url
-> Key
-> View Msg
}
, notFound : Static Gen.Params.NotFound.Params
}
-- TYPE MISMATCH ------------------ .elm-spa/generated/Gen/Pages.elm
The 3rd argument to `bundle` is not what I expect:
140| , customer__customer_ = bundle Pages.Customer.Customer_.page Model.Customer__Customer_ Msg.Customer__Customer_
^^^^^^^^^^^^^^^^^^^^^^^
This `Customer__Customer_` value is a:
Never -> Msg.Msg
But `bundle` needs the 3rd argument to be:
Pages.Customer.Customer_.Msg -> pagesMsg
Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!
-- TYPE MISMATCH ------------------ .elm-spa/generated/Gen/Pages.elm
The 2nd argument to `bundle` is not what I expect:
140| , customer__customer_ = bundle Pages.Customer.Customer_.page Model.Customer__Customer_ Msg.Customer__Customer_
^^^^^^^^^^^^^^^^^^^^^^^^^
This `Customer__Customer_` value is a:
Gen.Params.Customer.Customer_.Params -> () -> Model.Model
But `bundle` needs the 2nd argument to be:
Gen.Params.Customer.Customer_.Params
-> Pages.Customer.Customer_.Model
-> Model.Model
Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!