pointfreeco / swift-case-paths

🧰 Case paths extends the key path hierarchy to enum cases.
https://www.pointfree.co/collections/enums-and-structs/case-paths
MIT License
904 stars 105 forks source link

Add `CasePathIterable` and `CasePathReflectable` protocols #173

Closed stephencelis closed 2 months ago

stephencelis commented 2 months ago

While the macro recently introduced iteration (https://github.com/pointfreeco/swift-case-paths/pull/159) and "reflection" (https://github.com/pointfreeco/swift-case-paths/pull/158), there's no way to abstract over it. Adding it directly to the CasePathable protocol would be potentially source breaking, so instead we can introduce some new protocols.

stephencelis commented 2 months ago

@mbrandonw I think this is ready to go. The main thing is if we're happy with the naming. CasePathIterable seems non-controversial, but the CasePathReflectable naming may be a little strange given that it's defined on the AllCasePaths type. One might assume/consider that the root enum is the "reflectable" type, and the AllCasePaths is just doing the reflecting...so is there a better name? CasePathReflecting maybe? Though I can't think of any protocols with an "-ing" suffix off the top of my head.