Switch to normal field selectors and generic-lens#562
Switch to normal field selectors and generic-lens#562
Conversation
|
I didn't go too much into the code, but after looking at several files, I can see that we use a very limited set of Entire code required for declaring these functions: type Getting r s a = (a -> Const r a) -> s -> Const r s
foldMapOf :: Getting r s a -> (a -> r) -> s -> r
foldMapOf = coerce
has :: Getting Any s a -> s -> Bool
has l = getAny . foldMapOf l (\_ -> Any True)
(^.) :: s -> Getting a s a -> a
s ^. l = getConst (l Const s)
(^?) :: s -> Getting (First a) s a -> Maybe a
s ^? l = getFirst (foldMapOf l (First . Just) s) |
|
Right, so this PR drops the We still need the |
This adopts the approach discussed here: #465 (comment) That is: - We export normal, non-prefixed record selectors (still using `DuplicateRecordFields`, of course). - Users who want lenses can use `generic-lens`; `lsp` and `lsp-test` do this. - It's sensible for `lsp-types` to define some useful lenses that aren't derived from fields; these go in a `lsp-types-lens` component. I think the result is... fine? kcsongor/generic-lens#96 is a pain in some cases, but by and large using the generic lenses is quite nice. I also tried to just use `OverloadedRecordDot` instead of lenses where I could, since we now support 9.2 as our earliest version. I couldn't quite get rid of `lens` in `lsp`, it's too useful. I did get rid of it entirely in `lsp-types`, which was quite painful in at least one place. This would obviously be a huge breaking change, but I think it's the right direction.
463025b to
680d82e
Compare
This adopts the approach discussed here:
#465 (comment)
That is:
DuplicateRecordFields, of course).generic-lens;lspandlsp-testdo this.lsp-typesto define some useful lenses that aren't derived from fields; these go in alsp-types-lenscomponent.I think the result is... fine?
kcsongor/generic-lens#96 is a pain in some cases, but by and large using the generic lenses is quite nice.
I also tried to just use
OverloadedRecordDotinstead of lenses where I could, since we now support 9.2 as our earliest version. I couldn't quite get rid oflensinlsp, it's too useful. I did get rid of it entirely inlsp-types, which was quite painful in at least one place.This would obviously be a huge breaking change, but I think it's the right direction.