[GHC] #15459: Wredundant-constraints does not work when constraint synonym is used

GHC ghc-devs at haskell.org
Tue Jul 31 12:40:17 UTC 2018


#15459: Wredundant-constraints does not work when constraint synonym is used
-------------------------------------+-------------------------------------
        Reporter:  flip101           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.3
      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):

 Yes, this is a little awkward

 * `withWarning` has two separate constraints; its type is really curried,
 like this:
 {{{
 withWarning :: Show a => Ord a => [a] -> [a]
 }}}
 * `withoutWarnig` only has one constraint, a tuple. It is uncurried.  This
 is so even though it's only a synonym, so that if you ask say `:t
 withoutWarning` it'll display the type with the synonym.

 But the result is that the compound constraint for `withoutWarning` is in
 fact used (by `sort`).

 I'm sure it'd be possible to fix this, but there's a bit of a grey zone.
 What about
 {{{
 type family F a :: Constraint
 type instance F [a] = (Show a, Ord a)

 foo :: F [a] => [a] -> [a]
 }}}
 Do you expect a warning for that?   A type system is a degenerate form of
 this.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15459#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list