[GHC] #15813: -Wredundant-constrains emits warning even if constraint is narrowing type

#15813: -Wredundant-constrains emits warning even if constraint is narrowing type -------------------------------------+------------------------------------- Reporter: jvanbruegge | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Keywords: | Operating System: Linux Architecture: x86_64 | Type of failure: Incorrect (amd64) | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I am not sure if this is the same as #12700 , but when having a constraint that uses type equality to narrow down a type, -Wredundant-constraints still emits the warning. My particular example is: {{{#!hs class RowCons (label :: Symbol) (ty :: k) (tail :: Row k) (row :: Row k) | label row -> ty tail, label ty tail -> row instance (RowDelete s r ~ tail, RowPrepend s ty tail ~ r) => RowCons s ty tail r get :: forall s ty t r. RowCons s ty t r => Record r -> Proxy s -> ty get _ _ = undefined test_rec = get (Proxy :: Record ('Cons "foo" '[String]) (Proxy :: Proxy "foo") }}} With the RowCons constraint, the inferred type of test_rec is String (or [Char]), but without it it is an ambiguous `ty`. If the implementation of the type classes is needed, they can be found here: https://github.com/jvanbruegge/Megarecord/blob/f65fa5f29dc393e32d42fc8787241... I tested this with 8.6.1 and 8.4.3 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15813 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15813: -Wredundant-constrains emits warning even if constraint is narrowing type -------------------------------------+------------------------------------- Reporter: jvanbruegge | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by jvanbruegge: Old description:
I am not sure if this is the same as #12700 , but when having a constraint that uses type equality to narrow down a type, -Wredundant- constraints still emits the warning. My particular example is:
{{{#!hs class RowCons (label :: Symbol) (ty :: k) (tail :: Row k) (row :: Row k) | label row -> ty tail, label ty tail -> row
instance (RowDelete s r ~ tail, RowPrepend s ty tail ~ r) => RowCons s ty tail r
get :: forall s ty t r. RowCons s ty t r => Record r -> Proxy s -> ty get _ _ = undefined
test_rec = get (Proxy :: Record ('Cons "foo" '[String]) (Proxy :: Proxy "foo") }}} With the RowCons constraint, the inferred type of test_rec is String (or [Char]), but without it it is an ambiguous `ty`.
If the implementation of the type classes is needed, they can be found here: https://github.com/jvanbruegge/Megarecord/blob/f65fa5f29dc393e32d42fc8787241...
I tested this with 8.6.1 and 8.4.3
New description: I am not sure if this is the same as #12700 , but when having a constraint that uses type equality to narrow down a type, -Wredundant-constraints still emits the warning. My particular example is: {{{#!hs class RowCons (label :: Symbol) (ty :: k) (tail :: Row k) (row :: Row k) | label row -> ty tail, label ty tail -> row instance (RowDelete s r ~ tail, RowPrepend s ty tail ~ r) => RowCons s ty tail r get :: forall s ty t r. RowCons s ty t r => Record r -> Proxy s -> ty get _ _ = undefined test_rec = get (Proxy :: Record ('Cons "foo" '[String])) (Proxy :: Proxy "foo") }}} With the RowCons constraint, the inferred type of test_rec is String (or [Char]), but without it it is an ambiguous `ty`. If the implementation of the type families is needed, they can be found here: https://github.com/jvanbruegge/Megarecord/blob/f65fa5f29dc393e32d42fc8787241... I tested this with 8.6.1 and 8.4.3 -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15813#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15813: -Wredundant-constraints emits warning even if constraint is narrowing type -------------------------------------+------------------------------------- Reporter: jvanbruegge | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #16154 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * related: => #16154 Comment: I have not dug into this, but I bet it's the same as #16154, which has a good explanation of the cause. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15813#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15813: -Wredundant-constraints emits warning even if constraint is narrowing type -------------------------------------+------------------------------------- Reporter: jvanbruegge | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.6.1 checker) | Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect | (amd64) error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #16154 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * component: Compiler => Compiler (Type checker) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15813#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC