bracer icon indicating copy to clipboard operation
bracer copied to clipboard

Write Template Haskell to reduce boilerplate when extending parsers

Open patrickt opened this issue 10 years ago • 0 comments

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 ])

patrickt avatar May 30 '14 15:05 patrickt