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

GHC ghc-devs at haskell.org
Fri Dec 23 15:50:36 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 RyanGlScott):

 I made some progress in investigating the pattern synonyms codebase. This
 "partitioning" I wondered about in comment:7 is
 [http://git.haskell.org/ghc.git/blob/b4c3a66872a2b6e64fea9cc1f20ef4c8921ef7b6:/compiler/typecheck/TcSigs.hs#l303
 described] in `Note [The pattern-synonym signature splitting rule]`:

 {{{
 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
 }}}

 And in
 [http://git.haskell.org/ghc.git/blob/b4c3a66872a2b6e64fea9cc1f20ef4c8921ef7b6:/compiler/typecheck/TcPatSyn.hs#l102
 tcCheckPatSynDecl], this is implemented
 [http://git.haskell.org/ghc.git/blob/b4c3a66872a2b6e64fea9cc1f20ef4c8921ef7b6:/compiler/typecheck/TcPatSyn.hs#l135
 like so]:

 {{{#!hs
 let univ_fvs = closeOverKinds $
                (tyCoVarsOfTypes (pat_ty : req_theta) `extendVarSetList`
 explicit_univ_tvs)
     (extra_univ, extra_ex) = partition ((`elemVarSet` univ_fvs) .
 binderVar) implicit_tvs
     univ_bndrs = extra_univ ++ mkTyVarBinders Specified explicit_univ_tvs
     ex_bndrs   = extra_ex   ++ mkTyVarBinders Specified explicit_ex_tvs
     univ_tvs   = binderVars univ_bndrs
     ex_tvs     = binderVars ex_bndrs
 }}}

 So I think in order to fix this bug, we'd just need to implement something
 analogous to the above in `repHsPatSynSigType`. But I'm stuck: the code
 above requires calculating free variables using `tyCoVarsOfTypes`, which
 takes `[Type]` as an argument. But in `repHsPatSynSigType`, we don't have
 `Type`s, we have `HsType`s! Is there an `HsType` counterpart to
 `tyCoVarsOfTypes` somewhere in the GHC codebase?

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


More information about the ghc-tickets mailing list