I’ve been following the Elm Guide and I’m currently on the forms section.
In trying to add validation to the model, I’ve run into some duplication across case branches - I was wondering if this could be written more elegantly? Thanks!
update : Msg -> Model -> Model
update msg model =
case msg of
NameChange name ->
-- Review: can the following block (which repeats thrice) be refactored?
let
newModel =
{ model | name = name }
in
{ newModel | validationModel = validate newModel }
PasswordChange password ->
let
newModel =
{ model | password = password }
in
{ newModel | validationModel = validate newModel }
PasswordAgainChange passwordAgain ->
let
newModel =
{ model | passwordAgain = passwordAgain }
in
{ newModel | validationModel = validate newModel }