New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for existing records #26
Comments
Doesn't sound too unreasonable. Cc @DoctorRyner as I imagine such a thing would be useful to him. I guess I'd like to understand why you are using this preprocessor. Is it just for the . syntax on new GHC versions? If so, we could switch to the real GHC instances, ditch a lot of complexity and avoid set field entirely. For syntax, one early version of the library made "x{}" a setField but left "x {}" alone - should that be reinstated? |
Thanks for the quick reply Neil! I'm on GHC 8.2 and want to use your preprocessor as a better alternative to DuplicateRecordFields because DRF's lack of type inference is a bit annoying. I'm not sure if I follow your suggestion about avoiding setField entirely. Wouldn't it make nested updates impossible even on newer GHC versions? Re the syntax, I don't have a strong preference here, although the difference between "x{}" and "x {}" seems a bit too subtle and possibly error-prone. |
Currently, I switched back to generic-lens + OverloadedLabels because of #24
I use it to simplify my code, generic-lens are just way too verbose and use annoying "syntax" just to access fields that turn something simple like test v1 v2 = v1.x + v2.z + v1.y * v2.y into this mess test v1 v2 = v1 ^. #x + v2 ^. #z + v1 ^. #y * v2 ^. #y I find Also, I use 8.6.5 and 8.4.4 most of the time |
I appreciate that |
Thank you, I just noticed this change and I'm considering to switch back from generic-lens :) |
I understand this issue has been discussed briefly in #24 but I think it should be re-opened.
Enabling the preprocessor on a per-file basis requires a code reorganisation while adding manual instances of HasField is unnecessary boilerplate.
Is there a reason why we can't add a bit of syntax (say, a double curly bracket) that would ignore the
setField
substitution in certain record update expressions? E.g.c {{ name = "Old " ++ name c }}
This way we could have the existing record behaviour when we need it (e.g. interfacing with records in 3rd party libraries) and the new dot-behaviour when we want it.
The text was updated successfully, but these errors were encountered: