Support NoFieldSelectors and DuplicateRecordFields#1379
Support NoFieldSelectors and DuplicateRecordFields#1379parsonsmatt merged 3 commits intoyesodweb:masterfrom
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
| , Value(Object) | ||
| , eitherDecodeStrict' | ||
| , object | ||
| , withObject |
There was a problem hiding this comment.
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:
@sincedeclarations to the Haddockstylish-haskellon any changed files..editorconfigfile for details)After submitting your PR:
(unreleased)on the Changelog