I can see from plenty of Q&As that cpp is the usual preprocessor for Haskell source; but that it isn't a good fit for the job. What other options are there?
Specifically:
- Haskell syntax is newline-sensitive and space/indent-sensitive -- unlike
C, socppjust tramples on whitespace; 'in Haskell might surround a character literal, but also might be part of an identifier (in which case it won't be paired) -- butcppcomplains if not a char literal;\gets a trailing space inserted -- which is not a terrible inconvenience, but I'd prefer not.
I'm trying to produce a macro to generate an instance from parameters for a newtype type and corresponding data constructor. It needs to generate both the instance head and constraints and a method binding. By just slotting the constructors into an instance skeleton.
(Probably Template Haskell could do this; but it seems rather a large hammer.)