[GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

GHC - devs mailing list
#16311: Suggest -XExistentialQuantification for 'forall' in data declarations
-------------------------------------+-------------------------------------
           Reporter:  int-index      |             Owner:  (none)
               Type:  task           |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.6.3
  (Parser)                           |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Phab:D5180 introduced a slight regression to the error messages. In this
 code

 {{{#!hs
 data T = forall a. MkT a
 }}}

 GHC used to complain

 {{{
 rnfail053.hs:5:10:
     Not a data constructor: ‘forall’
     Perhaps you intended to use ExistentialQuantification
 }}}

 but then the message has become

 {{{
 rnfail053.hs:5:18: error:
     Illegal symbol '.' in type
     Perhaps you intended to use RankNTypes or a similar language
     extension to enable explicit-forall syntax: forall <tvs>. <type>
 }}}

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

GHC - devs mailing list
#16311: Suggest -XExistentialQuantification for 'forall' in data declarations
-------------------------------------+-------------------------------------
        Reporter:  int-index         |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
  (Parser)                           |
      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:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * cc: RyanGlScott (added)


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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#16311: Suggest -XExistentialQuantification for 'forall' in data declarations
-------------------------------------+-------------------------------------
        Reporter:  int-index         |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
  (Parser)                           |
      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 RyanGlScott):

 I'm especially interested in this ticket because I recently implemented a
 prototype of the [https://github.com/ghc-proposals/ghc-proposals/pull/193
 forall-always-a-keyword-in-types] proposal, and to my surprise, this
 caused the stderr for `rnfail053` to change even further:

 {{{#!diff
 diff -uw "rename/should_fail/rnfail053.run/rnfail053.stderr.normalised"
 "rename/should_fail/rnfail053.run/rnfail053.comp.stderr.normalised"
 --- rename/should_fail/rnfail053.run/rnfail053.stderr.normalised
 2019-02-13 06:48:37.043855139 -0500
 +++ rename/should_fail/rnfail053.run/rnfail053.comp.stderr.normalised
 2019-02-13 06:48:37.043855139 -0500
 @@ -1,5 +1,7 @@

  rnfail053.hs:5:10:
 -    Illegal symbol ‘forall’ in type
 -    Perhaps you intended to use RankNTypes or a similar language
 -    extension to enable explicit-forall syntax: ‘forall <tvs>. <type>’
 +     Data constructor ‘MkT’ has existential type variables, a context, or
 a specialised result type
 +        MkT :: forall a. a -> T
 +        (Enable ExistentialQuantification or GADTs to allow this)
 +     In the definition of data constructor ‘MkT’
 +      In the data type declaration for ‘T’
 }}}

 It wasn't clear to me at the time whether this was an upgrade or downgrade
 in error message quality, so I worked around it by making this change to
 the parser:

 {{{#!diff
 diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
 index 820144d930..e3423669bf 100644
 --- a/compiler/parser/Parser.y
 +++ b/compiler/parser/Parser.y
 @@ -2275,7 +2293,11 @@ constr :: { LConDecl GhcPs }
                         (fst $ unLoc $2) }

  forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr GhcPs]) }
 -        : 'forall' tv_bndrs '.'       { sLL $1 $> ([mu AnnForall $1,mj
 AnnDot $3], Just $2) }
 +        : 'forall' tv_bndrs '.'       {% do { hintExplicitForall $1
 +                                            ; pure $ sLL $1 $>
 +                                                ( [ mu AnnForall $1
 +                                                  , mj AnnDot $3 ]
 +                                                , Just $2) } }
          | {- empty -}                 { noLoc ([], Nothing) }
 }}}

 That reverted the error message back to what it was before (mentioning
 `RankNTypes`). But perhaps the error message really ought to mention
 `ExistentialQuantification`.

 Some related questions: there are currently two distinct error messages
 that mention not enabling `ExistentialQuantification`:

 * There's the one in the original description of this ticket (the "`Not a
 data constructor: ‘forall’`" one).
 * There's also the one I mentioned in this comment (the "`has existential
 type variables, a context, or a specialised result type`" one).

 Do we need both? Or is there a way we could consolidate the two somehow?
 Would the answer change if we made `forall` permanently a keyword in
 types?

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#16311: Suggest -XExistentialQuantification for 'forall' in data declarations
-------------------------------------+-------------------------------------
        Reporter:  int-index         |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
  (Parser)                           |
      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 int-index):

 > Do we need both? Or is there a way we could consolidate the two somehow?
 Would the answer change if we made forall permanently a keyword in types?

 No, we don't need both, and the `forall` proposal makes the matters
 trivial. See https://gitlab.haskell.org/ghc/ghc/merge_requests/363

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#16311: Suggest -XExistentialQuantification for 'forall' in data declarations
-------------------------------------+-------------------------------------
        Reporter:  int-index         |                Owner:  (none)
            Type:  task              |               Status:  patch
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.6.3
  (Parser)                           |
      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:                    |
-------------------------------------+-------------------------------------
Changes (by int-index):

 * status:  new => patch
 * milestone:   => 8.8.1


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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#16311: Suggest -XExistentialQuantification for 'forall' in data declarations
-------------------------------------+-------------------------------------
        Reporter:  int-index         |                Owner:  (none)
            Type:  task              |               Status:  patch
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.7
  (Parser)                           |
      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:                    |  https://gitlab.haskell.org/ghc/ghc/merge_requests/363
-------------------------------------+-------------------------------------
Changes (by int-index):

 * differential:   => https://gitlab.haskell.org/ghc/ghc/merge_requests/363
 * version:  8.6.3 => 8.7


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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #16311: Suggest -XExistentialQuantification for 'forall' in data declarations

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#16311: Suggest -XExistentialQuantification for 'forall' in data declarations
-------------------------------------+-------------------------------------
        Reporter:  int-index         |                Owner:  (none)
            Type:  task              |               Status:  merge
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.7
  (Parser)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
                                     |  rename/should_fail/rnfail053
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |  https://gitlab.haskell.org/ghc/ghc/merge_requests/363
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * status:  patch => merge
 * testcase:   => rename/should_fail/rnfail053


Comment:

 Landed in
 [https://gitlab.haskell.org/ghc/ghc/commit/887454d8889ca5dbba70425de41d97939cb9ac60
 887454d8889ca5dbba70425de41d97939cb9ac60].

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets