Giter Site home page Giter Site logo

Update Functions about elm-protobuf HOT 4 CLOSED

tiziano88 avatar tiziano88 commented on July 24, 2024
Update Functions

from elm-protobuf.

Comments (4)

tiziano88 avatar tiziano88 commented on July 24, 2024

Thanks for offering your advice and willing to help @dmattia ! I am not sure whether introducing additional combinators for this kind of updates is any more readable than just using the plain record update syntax.

In your example, the "plain" version would look like

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
  case msg of
    SomeMsg someStr someLong ->
      ( { model
        | stringField = someStr
        , longField = someLong
        }
      , Cmd.none )

which seems pretty readable to me?

from elm-protobuf.

dmattia avatar dmattia commented on July 24, 2024

It does to me as well. The bigger issue that I am hoping to help with is updating nested records, where helper functions can make code considerably more concise and readable (subjective).

I really like the asXIn syntax alongside the setX methods, as described here:
https://medium.com/elm-shorts/updating-nested-records-in-elm-15d162e80480

from elm-protobuf.

tiziano88 avatar tiziano88 commented on July 24, 2024

I feel the same about nested records, and I wish elm had something like the lens package in Haskell for that. The closest I could find is https://github.com/bChiquet/elm-accessors , perhaps we could add support for generating those combinators in proto, but AFAICT the elm community (or at least @evancz) seems to discourage that pattern (see the message when typing lens into https://package.elm-lang.org/).

from elm-protobuf.

dmattia avatar dmattia commented on July 24, 2024

That's fair. I'm convinced enough that this isn't needed for now then.

from elm-protobuf.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.