bracer
bracer copied to clipboard
Write Template Haskell to reduce boilerplate when extending parsers
Right now, you can't do the following:
newtype CustomCParser a = CustomParser (CCParser a)
deriving (
, IdentifierParsing
, TypeParsing
, ExpressionParsing
, StatementParsing
)
because you can't use generalized newtype deriving to inherit the definition of type families, only typeclasses. So you have to do
instance TypeParsing CustomParser where
type TypeSig CustomParser = TypeSig CustomParser :+: MyNewDataType
parseTypeName = deepInject <$> parseTypeName
Would be cool to do some Template Haskell for this, so we could do
$(inheritParser ''TypeParsing ''CustomParser [ ''MyNewDataType ])