[GHC] #13526: -Wsimplifiable-class-constraints behaves differently with OVERLAPPING and OVERLAPPABLE
#13526: -Wsimplifiable-class-constraints behaves differently with OVERLAPPING and OVERLAPPABLE -------------------------------------+------------------------------------- Reporter: cocreature | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{ {-# LANGUAGE FlexibleContexts, FlexibleInstances, FunctionalDependencies, MultiParamTypeClasses, UndecidableInstances #-} module Test where import Foreign.Ptr class DescendentOf a b where upCast :: Ptr b -> Ptr a upCast = castPtr class ChildOf b c | c -> b instance {-# OVERLAPPING #-} DescendentOf a a where upCast = id instance (DescendentOf a b, ChildOf b c) => DescendentOf a c data Value operateOnValue :: Ptr Value -> IO () operateOnValue _ = pure () typeOf :: DescendentOf Value v => Ptr v -> IO () typeOf = operateOnValue . upCast }}} The above code results in the following warning with GHC 8.2rc1 {{{ Test.hs:21:11: warning: [-Wsimplifiable-class-constraints] The constraint ‘DescendentOf Value v’ matches an instance declaration instance (DescendentOf a b, ChildOf b c) => DescendentOf a c -- Defined at Test.hs:14:10 This makes type inference for inner bindings fragile; either use MonoLocalBinds, or simplify it using the instance | 21 | typeOf :: DescendentOf Value v => Ptr v -> IO () }}} However, if I add `OVERLAPPABLE` to the second instance, the warning disappears because such instances are explicitly excluded in the check for this warning. I think it would make sense to silence this warning also if there is any `OVERLAPPING` instance that matches. The current warning is confusing since in this case the constraint actually can’t be simplified without changing the meaning of the code (the first instance would no longer match). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13526> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13526: -Wsimplifiable-class-constraints behaves differently with OVERLAPPING and OVERLAPPABLE -------------------------------------+------------------------------------- Reporter: cocreature | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 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 Simon Peyton Jones <simonpj@…>): In [changeset:"65b185d4886b4efa3efe3cc5ecc8dd6e07d89afe/ghc" 65b185d4/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="65b185d4886b4efa3efe3cc5ecc8dd6e07d89afe" Be less aggressive about fragile-context warrnings In the implementation of WarnSimplifiableClassConstraints, be less aggressive about reporting a problem. We were complaining about a "fragile" case that in fact was not fragile. See Note [Simplifiable given constraints] in TcValidity. This fixes Trac #13526. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13526#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13526: -Wsimplifiable-class-constraints behaves differently with OVERLAPPING and OVERLAPPABLE -------------------------------------+------------------------------------- Reporter: cocreature | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T13526 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => typecheck/should_compile/T13526 Comment: Excellent point. There is a nice easy fix. Could be merged to the branch. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13526#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13526: -Wsimplifiable-class-constraints behaves differently with OVERLAPPING and OVERLAPPABLE -------------------------------------+------------------------------------- Reporter: cocreature | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T13526 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13526#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13526: -Wsimplifiable-class-constraints behaves differently with OVERLAPPING and OVERLAPPABLE -------------------------------------+------------------------------------- Reporter: cocreature | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T13526 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by cocreature): Thank you for looking into this so quickly! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13526#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13526: -Wsimplifiable-class-constraints behaves differently with OVERLAPPING and OVERLAPPABLE -------------------------------------+------------------------------------- Reporter: cocreature | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T13526 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.2` as da17a35a80a2075a76163375175f15b3119b9711. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13526#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC