-
Notifications
You must be signed in to change notification settings - Fork 292
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
Support NoFieldSelectors and DuplicateRecordFields #1379
Conversation
* Getters are defined in terms of explicit record pattern match instead of a field selector function * It defines record updates verbosely in order to disambiguate duplicate fields
@@ -78,10 +78,10 @@ import Data.Aeson | |||
, Value(Object) | |||
, eitherDecodeStrict' | |||
, object | |||
, withObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is due to stylish-haskell
This is a great improvement - I've definitely run into issues before where you'd have a model file like:
and it would fail to compile. Thanks for the PR! |
Would you be willing to add a test module here? Mostly so we can avoid breaking this with a regression in the future Probably something like: #if __GLASGOW_HASKELL__ >= 902
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE DuplicateRecordFields #-}
#endif
module NoFieldSelectorTest where
#if __GLASGOW_HASKELL__ >= 902
import ...
mkPersist [persistLowerCase|
something that triggers a bug
|]
spec :: Spec
spec = it "compiles" True
#else
spec :: Spec
spec = do
it "only works with GHC 9.2 or greater" $ do
pendingWith "only works with GHC 9.2 or greater"
#endif |
Added (using your example almost as-is). Unfortunately it turns out that disambiguating fields isn't enough to solve the User vs UserProfile problem because it also defines type constructors ( |
Alas! Good point on that 😄 I'll get this merged and released once CI is done. This should be a patch-level bump. |
Released as |
Thanks! This is a big step for my ambition for greater records! |
Before submitting your PR, check that you've:
@since
declarations to the Haddockstylish-haskell
on any changed files..editorconfig
file for details)After submitting your PR:
(unreleased)
on the Changelog