2
Каков правильный/лучший способ обновления записи в записи?elm - обновление записи в записи
Следующая попытка:
type alias Model =
{ pageView : PageView
, landingPageModel : Dict
}
--update
update : Action -> Model -> Model
update action model =
case action of
ChangePage pView ->
{ model | pageView = pView }
PostCode pCode ->
let
lPModel =
model.landingPageModel
newlPModel =
{ lPModel | postCode = pCode }
in
{ model | landingPageModel = newlPModel }
дал эту ошибку:
The type annotation for `update` does not match its definition.
19│ update : Action -> Model -> Model
^^^^^^^^^^^^^^^^^^^^^^^^
The type annotation is saying:
Action
-> { ..., landingPageModel : Dict }
-> { ..., landingPageModel : Dict }
But I am inferring that the definition has this type:
Action
-> { ..., landingPageModel : { a | postCode : String } }
-> { ..., landingPageModel : { a | postCode : String } }
Это несколько удивительно - не буквальное Dict
обновление типа Dict
?
Этот вопрос не имеет ничего общего со словарями, пожалуйста, отредактируйте его. – halfzebra
спасибо, что было сделано – category
Это библиотека объективов Elm, но обратите внимание на предупреждения о вреде для здоровья - я никогда не использовал ее на практике http://package.elm-lang.org/packages/evancz/focus/2.0.0/ –