[GHC] #11948: GHC forgets constraints

GHC ghc-devs at haskell.org
Fri Apr 22 12:57:45 UTC 2016


#11948: GHC forgets constraints
-------------------------------------+-------------------------------------
        Reporter:  crockeea          |                Owner:
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:  8.0.2
       Component:  Compiler          |              Version:  7.10.3
      Resolution:  fixed             |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  GHC rejects       |            Test Case:
  valid program                      |  typecheck/should_fail/T11948
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by crockeea):

 Thanks for your work on this Simon. The warning is better than the current
 state of things. I do want to point out that while there are good reasons
 for simplifying constraints from instance declarations, it can also be a
 good thing **not** to.

 In particular, simplifying constraints to help GHC can result in code that
 has the LHS of the instance in many places, all of which have to be
 updated when the instance changes. Second, these simplified contexts might
 not make sense. For example: if I have an `instance (F a) => Foo (G a)`
 and a function `bar :: Foo (G a) => ...` where `bar` calls some function
 of `Foo` on type `G a`, GHC will now suggest (if I understand correctly)
 `bar :: (F a) => ...`. However, `bar` might not use any functions from `F`
 at all, and it may not involve the type `a` directly. Someone not
 intimately familiar with the code could be confused by this odd set of
 constraints.

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


More information about the ghc-tickets mailing list