Comments (2)
That makes sense @stephencelis -- thanks so much for explaining your thinking about this. I see how this is more of an introduction to the concept before diving into applying it to structs.
I'll close this issue now.
Love the series!
from episode-code-samples.
Hi @timojaask!
I might misunderstand the meaning of "very composable", but it seems that this code is not very composable.
When we use the word "composition" what we mean is the ability to take 2 things and combine them into a 3rd thing. We consider things "more composable" when there's less ad hoc work required to do such combining. The reason why we consider functions "super composable" is that we can reach for things like <<<
and <>
to do the combining of existing functions, and we can decompose functions into smaller and smaller units that can be glued back together. So in this case, by modeling setters as functions, we can break them into smaller setters and glue them back together as we would with any function. Without these operations you'd need to do more ad-hoc work to combine mutations together. Does that make sense?
This only works if you touch all three elements of the nested tuple. What if you want a transformation that only updates one or two of the tuple's elements? The compiler will fail to infer the type for the remaining element(s).
You have to give the compiler a hint, for sure. Swift has a Generics Manifesto that details how this may improve over time, though, if "generic" variables ever become a thing.
This seems to contradict "very composable" and "easy to reuse code".
The tuple example is a bit of a toy that is definitely complicated by Swift generics, but the examples in the next episode are a bit less fussy, since they use key paths with more concrete types.
Does that all make sense?
from episode-code-samples.
Related Issues (20)
- 0167 Navigation is weird on iPad HOT 1
- Please fix the error Episode #76 ~ HOT 2
- [0171-modularization-pt1] Setting Up HOT 3
- modularization folders architecture HOT 1
- Missing episode 187: URL Route? HOT 1
- Cannot convert value of type - Examples will not compile using Xcode 13.3 HOT 2
- Request: Re-Record Episode 100 to 103 and Update Source Code HOT 3
- Episode 196: Runtime warning work only in half of the cases HOT 1
- minor bug in episode 198 sample HOT 1
- Code sample for episode 220 is missing HOT 1
- Strange navigation on episode 220 HOT 1
- Episode 2 -> Fish playground -> Ambiguous use of 'init(utf8String:)'
- Episode 0228 - Composable Navigation: Destinations sample code not found HOT 1
- navigationDestination not triggered HOT 3
- Modern SwiftUI: Standups App HOT 1
- 0148 Derived Behaviour - Animation HOT 2
- Is the source code for episode 150 unavailable? HOT 1
- Missing samples episodes code HOT 1
- @FocusState not working with new @BindableState API HOT 5
- UIApplication.shared.windows deprecated in iOS 15 HOT 1
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 episode-code-samples.