data SubTyCon = SubDataCon
{ subKey1 :: Text
, subKey2 :: Int
, subKey3 :: Maybe Bool
}
deriving (Generic, Show, Eq)
deriving (NestedParser) via (SubConfig SubTyCon)
We get this error when the constructor for SubConfig isn't imported
• Couldn't match representation of type ‘SubConfig SubTyCon’
with that of ‘SubTyCon’
arising from a use of ‘ghc-prim-0.10.0:GHC.Prim.coerce’
The data constructor ‘cfg-0.0.1.0:Cfg.Deriving.SubConfig.SubConfig’
of newtype ‘SubConfig’ is not in scope
• In the expression:
ghc-prim-0.10.0:GHC.Prim.coerce
@(Tree Text -> Either ConfigParseError (SubConfig SubTyCon))
@(Tree Text -> Either ConfigParseError SubTyCon)
(parseNestedConfig @(SubConfig SubTyCon))
The error is because of this coerce that I am doing (a trick I took from the deriving-aeson library)
instance (Generic a, GNestedParser (Rep a)) => NestedParser (SubConfig a) where
parseNestedConfig tree = coerce `asTypeOf` fmap SubConfig $ defaultParseNestedConfig defaultConfigOptions tree
It would be nice to either:
a) prevent this error altogether
b) provide a nicer error message
For the deriving via machinery here:
We get this error when the constructor for
SubConfig
isn't importedThe error is because of this
coerce
that I am doing (a trick I took from the deriving-aeson library)It would be nice to either: a) prevent this error altogether b) provide a nicer error message