I see I left out a required argument from what I want, which leads me to this:
update : Msg -> Model -> Model
update msg model =
case msg of
ChangedDripText string ->
updateWhen model isValidFloatString dripText string
ChangedHoursText string ->
updateWhen model isValidIntString simulationHoursText string
ChangedMinutesText string ->
updateWhen model isValidIntString simulationMinutesText string
dripText model val =
{ model | dripText = val }
simulationHoursText model val =
{ model | simulationHoursText = val }
simulationMinutesText model val =
{ model | simulationMinutesText = val }
updateWhen : Model -> (String -> Bool) -> (Model -> String -> Model) ->
String -> Model
updateWhen model pred updater candidate =
if pred candidate then
updater model candidate
else
model
… which is OK, but doesn’t take me to my happy place.
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.