The property expression approach to create lenses has been very useful, but has always been a hack. The fact that we parse the property expression function's source code with regular expressions at runtime doesn't inspire any confidence just from its description alone. We also had several problems integrating with different instrumentation tools.
This PR implements alternative approach to create lenses and views. It's just as type safe as the property expression way. It also allows you to use the auto-completion feature (only tested in VSCode though).
The rename refactoring unfortunately doesn't work with string keys. Maybe we can find a workaround, or maybe we can decide to live with it. I would like to deprecate the property expression thing at some point, but would only like to do that if it will not significantly worsen the development UX.
Changes in this PR:
[x] Another Lens.key overload that looks like this:
The property expression approach to create lenses has been very useful, but has always been a hack. The fact that we parse the property expression function's source code with regular expressions at runtime doesn't inspire any confidence just from its description alone. We also had several problems integrating with different instrumentation tools.
This PR implements alternative approach to create lenses and views. It's just as type safe as the property expression way. It also allows you to use the auto-completion feature (only tested in VSCode though).
The rename refactoring unfortunately doesn't work with string keys. Maybe we can find a workaround, or maybe we can decide to live with it. I would like to deprecate the property expression thing at some point, but would only like to do that if it will not significantly worsen the development UX.
Changes in this PR:
[x] Another
Lens.key
overload that looks like this:[x]
Atom.view
andAtom.lens
overloads to dokeyof
-typed views/lenses:This also adds several variadic overloads (up to 5 nested keys) for both
.view
and.lens
.Lens.unsafeKey
. Not even sure what was the original idea behind it, it's not used anywhere ATM.