6.8 unable to derive with higher-kinded variable (6.6 could)
simonpj at microsoft.com
Fri Apr 18 04:17:33 EDT 2008
| GHC 6.8 seems unable to derive (some?) instances for data types with
| higher-kinded variables. GHC 6.6 manages these just fine. See below.
| data T w = T (w Bool) deriving (Show)
| data ID x = ID x deriving (Show)
| main = print (T (ID False))
Look at the instance declaration you'd get
instance Show (w Bool) => Show (T w)
It's not clear that this leads to terminating instance resolution -- and on occasion it didn't! That's bad for a built-in mechanism like 'deriving'. So I tightened up the rules for derived instances, so the (inferred) context must be classes applied to type variable.
Nevertheless, if you write the instance decl yourself, GHC lets you:
data T w = T (w Bool)
deriving instance Show (w Bool) => Show (T w)
This uses the new 'standalone deriving' so that you can write the instance decl, including the context; by saying 'deriving' you ask GHC to fill in the methods in the standard way, which it does.
More information about the Glasgow-haskell-users