[GHC] #11099: Incorrect warning about redundant constraints

#11099: Incorrect warning about redundant constraints -------------------------------------+------------------------------------- Reporter: diatchki | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 (Type checker) | 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: -------------------------------------+------------------------------------- The following program results in an incorrect warning about a redundant constraint: {{{ {-# LANGUAGE TypeFamilies #-} type family SomeFun a f :: (SomeFun i ~ [a], Read a) => proxy i -> a f _ = read "HELLO" }}} This is the warning: {{{ Redundant constraint: SomeFun i ~ [a] In the type signature for: f :: (SomeFun i ~ [a], Read a) => proxy i -> a }}} I tried it on GHC version 7.11.20151029 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11099 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11099: Incorrect warning about redundant constraints -------------------------------------+------------------------------------- Reporter: diatchki | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.11 checker) | 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 rwbarton): I think redundant here means basically: the definition of `f` would be accepted without the constraint. It doesn't mean that the type of `f` would be the same if you removed the constraint. The idea is to catch constraints that aren't actually used in the function, so that you could make the type of the function more general. In that case the constraint really is redundant, right? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11099#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11099: Incorrect warning about redundant constraints -------------------------------------+------------------------------------- Reporter: diatchki | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.11 checker) | 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 diatchki): I don't see how it is redundant---without that constraint I couldn't write the required type for the function: notice that the constraint is used to compute the type of the output from the type of the input. If I was to remove the constraint, then the connection between the input and output type is lost, and so uses of this function would become ambiguous in some contexts. In other situations (e.g., the function `get` [wiki:Proposal/CustomTypeErrors#ExtendedExample here]) this would be not just ambiguous but also plain wrong. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11099#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11099: Incorrect warning about redundant constraints -------------------------------------+------------------------------------- Reporter: diatchki | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.11 checker) | 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 rwbarton): I understand why you don't want the warning, I'm just saying that the warning is working as designed. Perhaps it would be possible to divine the programmer's intent in this case and suppress the warning automatically. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11099#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11099: Incorrect warning about redundant constraints -------------------------------------+------------------------------------- Reporter: diatchki | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.11 checker) | 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 simonpj): * You want to give a signature to the function that is less polymorphic than its most general type. * You may have legitimate reasons for wanting to do so. * Insofar as you do so by adding a constraint that isn't used, GHC may complain if you use `-fwarn-redundant-constraints`. Hmm. We'd really like a per-function way of suppressing the warning. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11099#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11099: Incorrect warning about redundant constraints -------------------------------------+------------------------------------- Reporter: diatchki | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.11 checker) | Keywords: Resolution: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * keywords: => CustomTypeErrors -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11099#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC