Comments (4)
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.
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.
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.
That's fair. I'm convinced enough that this isn't needed for now then.
from elm-protobuf.
Related Issues (11)
- Support for proto2 syntax? HOT 10
- infix functions in generated decoders HOT 2
- Elm 0.19 upgrade not working HOT 2
- support gRPC services HOT 6
- Update tags to support Go modules HOT 3
- Incorrect code generated with type names
- Map support HOT 7
- LIst of items not decoding HOT 1
- enum as int32 HOT 9
- name collisions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elm-protobuf.