
#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): It's not a big deal, but I prefer the proposed change too. In my mind, when I write an instance {{{ instance C (Either a b) where ... }}} I'm really writing an instance for `Either a b` for each pair of specific, but unknown, types `a` and `b`. According to the class declaration {{{ class C x where type T x }}} I'm supposed to provide the value of `T` on the specific type `Either a b`. If I write `type T (Either b a) = ...`, then I haven't met that obligation. This argument is somewhat flimsy in that type variables in the head of an instance don't actually scope over the instance body in Haskell 98; but we're already so far outside Haskell 98 with associated type families that I don't mind. (With ScopedTypeVariables instance head type variables do scope over the body, which is the behavior most people expect, I think.) It also just seems more practical: I might reasonably read `type T (...) = b -> a` and doze off over the argument of `T`, expecting a sensible author to have made it match the instance head. Surprise! Technically this is a breaking change, but I feel that on balance, authors will be more glad to learn about non-matching associated type heads, which were probably unintentional, than annoyed that their code broke. However, we should do it either quickly, before the next 8.0 RC, or leave it until 8.2. Nothing critical about this change that I can see, so better not to slip it in at the last minute of a release. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11450#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler