
#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 RyanGlScott):
This is bogus, because the equation for `T` has the parameters to `Either` reversed.
Interesting, I was not aware of such a restriction on type family instances. Is this documented somewhere in the [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/type- families.html users' guide section] on type families? I was under the impression that as long as the instantiated type in the associated instance was equal to the instance head up to alpha equivalence, then it would be accepted, i.e., the above example is a valid type family instance, but the following is rejected with an error: {{{#!hs class C x where type T x instance C (Either a b) where type T (Either b (f a)) = b -> f a }}} {{{ • Type indexes must match class instance head Found ‘Either b (f a)’ but expected ‘Either a b’ • In the type instance declaration for ‘T’ In the instance declaration for ‘C (Either a b)’ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11450#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler