[GHC] #9820: Apparently inconsistent behaviour in the presence of OverlappingInstances

#9820: Apparently inconsistent behaviour in the presence of OverlappingInstances -------------------------------------+------------------------------------- Reporter: kosmikus | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- This report is inspired by http://stackoverflow.com/questions/27051640 /strange-behavior-when-adding-constraint-to-instance I'm not sure if it is a bug, but it certainly feels strange and inconsistent to me, so I'd like to get some clarification. Here's a self-contained example of the behaviour: {{{#!hs {-# LANGUAGE FlexibleInstances, OverlappingInstances #-} module Overlap where class C a where foo :: a -> a instance C a where foo = id instance C Int where foo = (+1) -- Note that this one does not mention class C anywhere: class D a where bar :: a -> a instance D a where bar = foo -- this works and picks the 'C a' instance always -- The following does not compile without IncoherentInstances: {- baz :: a -> a baz = foo -} }}} I'm surprised that the definitions of `bar` and `baz` are treated differently. Shouldn't they either both require `IncoherentInstances`, or both work? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9820 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9820: Apparently inconsistent behaviour in the presence of OverlappingInstances -------------------------------------+------------------------------------- Reporter: kosmikus | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by kosmikus): * component: Compiler => Compiler (Type checker) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9820#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9820: Apparently inconsistent behaviour in the presence of OverlappingInstances -------------------------------------+------------------------------------- Reporter: kosmikus | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by crockeea): * cc: ecrockett0@… (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9820#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9820: Apparently inconsistent behaviour in the presence of OverlappingInstances -------------------------------------+------------------------------------- Reporter: kosmikus | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: #7296 None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by goldfire): * related: => #7296 Comment: This is by design, for better or worse. See #7296 for an explanation. I'm sure the fix -- that is, redesign -- for that ticket and this one will be the same, but I think it's worth leaving both tickets open, as the examples are slightly different. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9820#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9820: Apparently inconsistent behaviour in the presence of OverlappingInstances -------------------------------------+------------------------------------- Reporter: kosmikus | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7296 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => duplicate Comment: Replying to [comment:3 goldfire]:
This is by design, for better or worse. See #7296 for an explanation. I'm sure the fix -- that is, redesign -- for that ticket and this one will be the same, but I think it's worth leaving both tickets open, as the examples are slightly different.
Duplicates tickets slow down sweeps of the bug tracker. Since #7296 references this ticket, I think it's safe to close this one. Yell if you disagree! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9820#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC