[Haskell-cafe] Generic "annotations" on type definitions
Li-yao Xia
lysxia at gmail.com
Sun Sep 11 09:19:23 UTC 2022
> Doesn't this require TH? A primary constraint here is using generics
only, since TH has many undesirable properties.
What syntax the metadata comes in is orthogonal to whether it's provided
and processed using TH. That goes back to this previous question of yours:
> Would it be technically feasible to add such a thing to
GHC'sĀ Generics support?
Yes, it is technically feasible to extend GHC generics to reflect as
much metadata as you want. It's a matter of deciding what syntax it's
going to come in (whether in types, comments, or whatever else), how
it's going to be encoded (via an extra `Meta` field, constructor, or
whatever), and correspondingly adapting the code that generates Generic
instances.
However, changing GHC is something that takes a lot of effort. A
short-term compromise is to reimplement the deriving of Generic
instances in TH. TH would only be used for that, then the processing of
that metadata by applications can be done purely in Haskell.
Li-yao
More information about the Haskell-Cafe
mailing list