To provide a more real-world example, we covered a compelling reason for enum key paths/properties this week on Point-Free:
Though this video is behind a paywall, our code is always open source:
In particular we show how reducer architecture can be modularized and reconstituted using a couple succinct operations:
- An operation that converts
Reducer<LocalState, LocalAction>
toReducer<GlobalState, GlobalAction>
- An operation that combines reducers that work on the same state and action type together
The first operation cannot succinctly transform LocalAction
s into GlobalAction
s in a performant manner without compiler help and enum properties and key paths perfectly handle this today (with a little boilerplate that ideally the compiler handles for us).