-
Notifications
You must be signed in to change notification settings - Fork 1
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
Document best practice setup for labelOpticDeriver #4
Comments
Thanks! I agree, the docs need improvement. I think it would be best to cover such details in the Haddocks of the according derivers. Not sure what you meant by placing the docs in the TemplateHaskell codegen. |
It's worth mentioning that OverloadedRecordDot was not a thing when the docs here were written, so the compatibility with it was not mentioned. It'd be great to have the instructions on how to use "domain" with OverloadedRecordDot covered. |
I meant define/export another top level stdDeriver without hasField/isLabelDeriver in DomainOptics module (name it stdOpticsDeriver?). Currently it must be exported from a separate module in project just to make TemplateHaskell stages happy. Yes, I agree Haddock is the best place, maybe put all of above under stdOpticsDeriver. |
Understood. I'm actually on the fence about it. It works with the setting I gave above. Pros is it looks nicer (no %^~# chars :-) if all you have are records. Cons is that it can't handle Affine fields for sum types (ie. runtime errors). |
Hi @nikita-volkov,
I found this part of README document is not sufficient for labelOpticDeriver.
domain/README.md
Line 525 in 062d559
declare (Just (False, False))
is set to False, hasFieldDeriver in stdDeriver produces "Illegal instance declaration for GHC.Records.HasField ... already has a field ...", which labelOpticDeriver also uses. Removing hasFieldDeriver fixes the compile error.declare (Just (False, False))
, it's best to enable these GHC extentions:Just want to share them first, and discuss where the best of places to put them (documentation or TemplateHaskell codegen).
Cheers!
The text was updated successfully, but these errors were encountered: