
#9918: GHC chooses an instance between two overlapping, but cannot resolve a clause within the similar closed type family -------------------------------------+------------------------------------- Reporter: qnikst | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): I agree with Simon's analysis. The fact that thinking about infinite types means closed type families are less useful in more prosaic situations is annoying. But I don't know a way around this. About Simon's interesting point (2): Some testing that I've done has made me even more confused, because I can't seem to witness the inconsistency. Are you sure that `OverlappingInstances` works here, even to select the `MonadRaise m m` instance? In my example, I was unable to get GHC to commit to the tyvars-equal instance without `IncoherentInstances` -- behavior I agree with. (It would destroy the type system to allow `IncoherentInstances`-like behavior with closed type families!) I will say that your technique of using closed type families to produce some switch to control instance selection to avoid overlapping instances is a good way to do this. Of course, instance chains would be better -- which, of course, are just like closed type families for class instances. Since we don't have instance chains, you're doing the next-best thing, in my opinion. My bottom line: I'm a little confused here, too. I believe that if GHC treats overlapping instances without the infinite-type reasoning, it would be possible to squeeze out proper incoherence among instances even without `IncoherentInstances`. But I couldn't seem to get it to happen! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9918#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler