
#15125: Typeclass instance selection depends on the optimisation level -------------------------------------+------------------------------------- Reporter: nicuveo | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.2 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 AntC):
This seems inconsistent with the ​documented behaviour of incoherent instances?
The naming is deliberate: only use `INCOHERENT` to diagnose behaviour you don't understand; never rely on ghc consistently picking an instance. The behaviour you're seeing in 8.4.2 is following the documentation. The critical part of that doco is
Eliminate any candidate **IX** for which ''both'' of the following hold:
The second sub-bullet doesn't hold, because neither instance is marked ''overlapping''/''overlappable''. So I'd expect to always pick the more general instance, marked `INCOHERENT`. Then I agree the optimisation level shouldn't influence instance selection. I guess that in optimising for module B, ghc forces the instance selection. Never the less, just don't use `INCOHERENT`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15125#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler