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

GHC ghc-devs at haskell.org
Fri Oct 26 21:54:22 UTC 2018


#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/f65fa5f29dc393e32d42fc87872416ec02405784/src/Megarecord.hs

 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


More information about the ghc-tickets mailing list