
It's simple. Consider {{{ class C v where type T a b v cd }}} In any instance declaration, the type in the `v` position of the `type` instance must be the same as in the instance header: {{{ instance ... => C ty where type T p q ty r s = <rhs> }}} I think we do (or at least should) also insist that `p`, `q`, `r`, `s` are distinct type variables, otherwise the type instance is more specific
#11450: Associated types at wrong type in instance -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Replying to [comment:8 simonpj]: than the class instance, but that's a separate matter. We don't and I don't think we should. Isn't it okay to define multiple instances that refine the other parameters, like this (currently accepted)? {{{ class C v where type T v w instance C (Either a b) where type T (Either a b) Int = a type T (Either a b) Char = b }}} In fact you're not obliged to provide any equations for `T` at all (though we do warn in that case). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11450#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler