[GHC] #2893: Implement "Quantified constraints" proposal

GHC ghc-devs at haskell.org
Thu Mar 1 23:57:41 UTC 2018


#2893: Implement "Quantified constraints" proposal
-------------------------------------+-------------------------------------
        Reporter:  porges            |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  ⊥
       Component:  Compiler          |              Version:  6.10.1
      Resolution:                    |             Keywords:
                                     |  QuantifiedConstraints
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #5927             |  Differential Rev(s):  Phab:D4353
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 I've added the superclass stuff
 {{{
 commit 910dfcfeadc4f132e887bc4adf5ac2e17a29d99b
 Author: Simon Peyton Jones <simonpj at microsoft.com>
 Date:   Thu Mar 1 23:32:29 2018 +0000

     Add superclasses to quantified constraints

     This patch adds suppport for superclasses to quantified constraints.
     For example (contrived):

       f :: (forall a. Ord a => Ord (m a)) => m a -> m a -> Bool
       f x y = x==y

     Here we need (Eq (m a)); but the quantifed constraint deals only
     with Ord.  But we can make it work by using its superclass.

     This behaviour finally delivers on the promise of comment:30 of
     Trac #9123: we can write an implication constraint that solves
     the problem of higher-kinded roles.  Test
     quantified-constraints/T8123 demonstrates this in action.

  compiler/basicTypes/Id.hs                        |   2 +-
  compiler/typecheck/Inst.hs                       |   4 +-
  compiler/typecheck/TcCanonical.hs                | 180
 ++++++++++++++---------
  compiler/typecheck/TcErrors.hs                   |   4 +-
  compiler/typecheck/TcEvTerm.hs                   |   5 +-
  compiler/typecheck/TcEvidence.hs                 |  74 ++++++----
  compiler/typecheck/TcHsSyn.hs                    |  23 ++-
  compiler/typecheck/TcInstDcls.hs                 |   2 +-
  compiler/typecheck/TcInteract.hs                 |  61 ++++----
  compiler/typecheck/TcMType.hs                    |   6 +-
  compiler/typecheck/TcPatSyn.hs                   |   7 +-
  compiler/typecheck/TcPluginM.hs                  |   2 +-
  compiler/typecheck/TcRnTypes.hs                  |  62 ++++++--
  compiler/typecheck/TcSMonad.hs                   | 119 +++++++--------
  compiler/typecheck/TcSimplify.hs                 |   2 +-
  compiler/typecheck/TcType.hs                     |   2 +-
  compiler/types/Class.hs                          |  54 ++++---
  compiler/types/Kind.hs                           |   2 +
  testsuite/tests/quantified-constraints/T2893b.hs |  24 ---
  testsuite/tests/quantified-constraints/T2893c.hs |  15 ++
  testsuite/tests/quantified-constraints/T9123.hs  |  24 +++
  testsuite/tests/quantified-constraints/T9123a.hs |  26 ++++
  testsuite/tests/quantified-constraints/all.T     |   5 +
  23 files changed, 426 insertions(+), 279 deletions(-)
 }}}
 So now all the features I was planning are implemented.

 Give it a whirl!

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


More information about the ghc-tickets mailing list