
Conor writes: <some wonky types>
newtype Copy a = Copy a deriving Show
data Wonky f = Wonky | Manky (f (Wonky f)) deriving Show
show (Wonky :: Wonky Copy)
I don't want to start an argument about how to solve this problem. I do want to suggest that, for the time being, it would be better to reject `deriving Show' for type constructors like Wonky (ie those with higher-kind parameters) than to generate instances which break the compiler.
Or am I just being a spoilsport?
Rejecting such things might be a bit extreme, for example, you could drop the 'deriving Show' on 'Copy a', define: instance Show (Copy a) where show _ = "whatever" then: show (Wonky :: Wonky Copy) is fine and does not result in an infinite loop of context reduction. Of course this makes the example even wonkier ... (In another post Tom Pledger illustrates another example: data Sport f = Sport | Association (f Bool) deriving Show test = show (Sport :: Sport Maybe) where higher kinded arguments do not cause any trouble). The context reducer could probably do a better job at detecting when it is in an infinite loop: Show (Wonky Copy) --> Show (Copy (Wonky Copy)) --> Show (Wonky Copy) ... Cheers, Bernie.