[GHC] #15334: (forall x. c x, forall x. d x) is not equivalent to forall x. (c x, d x)

GHC ghc-devs at haskell.org
Mon Jul 2 21:06:10 UTC 2018


#15334: (forall x. c x, forall x. d x) is not equivalent to forall x. (c x, d x)
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:
      Resolution:                    |  QuantifiedConstraints
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Read [https://github.com/Gertjan423/ghc-proposals/blob/quantified-
 constraints/proposals/0000-quantified-constraints.rst the proposal] esp
 Section 3.2

 Would you write
 {{{
 instance (Functor (T a), Traversable (T a), Foldable (T a_)) where ...
 }}}
 No! An instance declaration is for a class, and takes the form
 {{{
 instance blah => C t1 .. tn where ...
 }}}
 where `C` is a class.

 Same with quantified constraints, as the syntax (tries to) make clear.

 I suppose that it's accepted because `(,,)` is a class but really I think
 it should be rejected.

 In fact
 {{{
 instance (Eq (T a), Ord (T a)) where {}
 }}}
 is not rejected out of hand, but elicits
 {{{
     * No instance for (Ord (T a))
         arising from the superclasses of an instance declaration
     * In the instance declaration for `(Eq (T a), Ord (T a))'
 }}}
 which is pretty confusing.  I think it's because `(c1, c2)` has
 superclasses `c1` and `c2`.

 My conclusion: both in top-level and quantified instances, we should
 reject a tuple in the head.

 OK?

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


More information about the ghc-tickets mailing list