How to deal with generic deriving for non-flat records
- Dominant language
- Haskell
- Stars
- 53
- Forks
- 45
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I wonder whether there is some preferred, idiomatic way to deal with things like
```haskell
data A = MkA
{ a1 :: Text
, a2 :: B
}
deriving stock Generic
deriving anyclass FromForm
data B = MkB
{ b1 :: Text
, ... }
deriving stock Generic
deriving anyclass FromForm
```
fails with `"No instance FromHttpApiData B arising from..."` because of this instance her:
```haskell
instance {-# OVERLAPPABLE #-} (Selector s, FromHttpApiData c) => GFromForm t (M1 S s (K1 i c)) where
gFromForm _ opts form = M1 . K1 <$> parseUnique key form
where
key = Text.pack $ fieldLabelModifier opts $ selName (Proxy3 :: Proxy3 s g p)
```
This is quite unfortunate because I would like to somehow indicate that this should be derived recursively somehow; perhaps we can indicate this somehow by using a newtype wrapper in `A`'s recursive field and then deriving everything newtype for it and then add an `{-# OVERLAPPING #-}` instance to the generic deriving? Though that would be quite the mess. I wonder what is a good way to do this.
Thanks in advance.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.