
Fergus Henderson wrote:
I think the issue here is that in ghc (with -fglasgow-exts), the "a" here refers to the same type variable "a" in the top of the instance declaration, which has already been constained, and cannot be constrained again.
Is that a bug or a feature?
With Haskell 98, it is a fresh type variable, for which the constraint is necessary.
Ok, if I view the local function as a new/independent function, I accept to add the Constraint, but that should be acceptable for ghc -fglasgow-exts as well (as is for hugs with extensions).
Try renaming the type variable as "b" in the inner declaration: the following should work both with and without -fglasgow-exts.
showsl :: Show b => List b -> ShowS
Yes, this works, but I never thought that the choice of "a" or "b" would matter. Christian
instance Show a => Show (List a) where showsPrec _ Nil = showString "[]" showsPrec _ l = showString "[" . showsl l . showString "]" where -- showsl :: List a -> ShowS -- for ghc -- showsl :: Show a => List a -> ShowS -- for hugs