There's an annoying "feature" that deriving instances are also affected by the RebindableSyntax
extension. Example of what I want to write:
{-# LANGUAGE RebindableSyntax #-}
import qualified Prelude
data Color = Red | Green | Blue | Periwinkle | Fuschia deriving (Prelude.Eq, Prelude.Ord)
This comes up with the error " Not in scope: `ifThenElse' ".
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With