[GHC] #13018: TH-spliced pattern synonym declaration fails to typecheck

GHC ghc-devs at haskell.org
Thu Dec 22 00:36:43 UTC 2016


#13018: TH-spliced pattern synonym declaration fails to typecheck
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |             Keywords:
      Resolution:                    |  PatternSynonyms
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):

 It's not a regression; it's a bug-fix!  See Trac #11224.

 Here's the note from `TcTySigs`:
 {{{
 Note [The pattern-synonym signature splitting rule]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Given a pattern signature, we must split
      the kind-generalised variables, and
      the implicitly-bound variables
 into universal and existential.  The rule is this
 (see discussion on Trac #11224):

      The universal tyvars are the ones mentioned in
           - univ_tvs: the user-specified (forall'd) universals
           - req_theta
           - res_ty
      The existential tyvars are all the rest
 }}}
 If you provide an explicit forall, they are all universals; but in this
 case we wanted 'b' to be an existential.   According to these rules you
 can say
 {{{
      pattern P :: b -> T a
 or
      pattern P :: forall a. () => forall b. b -> T a
 }}}
 We neglected to put this rule in the user manual: that should be fixed.
 '''Matthew or Ryan, might you do that?'''

 The TH problem is that TH is taking a quote with an implicit forall, and
 turning it into a TH data structure with an explicit forall.  When that is
 converted back into `HsSyn` it has an explicit forall, so we get `pattern
 P :: forall b a. b -> T a`.  So the round trip is not faithful.

 I wonder if we could just genertate TH syntax with an implicit forall?

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


More information about the ghc-tickets mailing list