That seems like a misfeature to me--the deriving
clause is full of built-in magic anyway, so I'm skeptical that derived instances using rebound syntax would be useful in practice. Now, if you could also rebind the deriving
clause itself and use a TH splice instead... but I digress.
I suspect the simplest and easiest solution is to use different modules. Put the data type definition in its own module, use the deriving
clause there with the Prelude functions in scope, then import the type in the module using rebindable syntax. If you need further modularity in your modules, note that StandaloneDeriving
also exists, and would let you define the types in one module (with RebindableSyntax
active), derive the instances in another module (without RebindableSyntax
), and import both from modules that actually use the type.
RebindableSyntax
? – Daniel Lyons