
#15636: Implication constraint priority breaks default class implementations -------------------------------------+------------------------------------- Reporter: i-am-tom | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1-beta1 Resolution: | Keywords: | QuantifiedConstraints Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): This happens just the same if you say {{{ instance (forall a. C a => D a) => D x where f _ = "uh oh" g = f }}} Why? Well `f :: D a => a -> String`, so the occurrence of `f` on the RHS of `g`'s defn here means that we need `D x`. How can we solve `D x`? * We can solve it from the quantified constraint, giving rise to a need for `C x` * We can solve it from the top level instance `instance ... => D x`. GHC picks the first, treating "local" constraints as shadowing "global" ones. The user manual specifies this. There was some discussion in the GHC proposal thread. So currently it's by-design. If you want to propose a different design, by all means do so! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15636#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler