Let's say I have a polymorphic type where one of the parameters is a higher-kinded type (* -> *
).
data Tricky m = Tricky { numbers :: m Int, genesis :: m String }
Is there a general way of deriving instances for such types without using arcane and unsafe language extensions?
I tried enabling StandaloneDeriving
so that I could specify the context:
deriving instance Show (m Int) => Show (Tricky m)
But GHC then complains about the constraint being no smaller than the instance head, and points me in the direction of UndecidableInstances
.
To summarise:
1. Should I simply go along with this advice, or is there a better way?
2. Are there any proposals to make this process easier?
3. Is it somehow wrong-headed to want to derive 'higher-kinded' instances? Would it be better to derive instances for a few concrete types instead (eg. Vector
, []
, Set
)