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

GHC ghc-devs at haskell.org
Thu Dec 22 02:34:59 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):

 From a quick investigation, the problematic code seems to be
 [http://git.haskell.org/ghc.git/blob/41ade95c068e77b916ff17865515eadb353a2358:/compiler/deSugar/DsMeta.hs#l904
 repHsPatSynSigType] in `DsMeta`:

 {{{#!hs
 repHsPatSynSigType :: LHsSigType Name -> DsM (Core TH.TypeQ)
 repHsPatSynSigType (HsIB { hsib_vars = implicit_tvs
                          , hsib_body = body })
   = addTyVarBinds (newTvs (impls ++ univs)) $ \th_univs ->
       addTyVarBinds (newTvs exis) $ \th_exis ->
     do { th_reqs  <- repLContext reqs
        ; th_provs <- repLContext provs
        ; th_ty    <- repLTy ty
        ; repTForall th_univs th_reqs =<< (repTForall th_exis th_provs
 th_ty) }
   where
     impls = map (noLoc . UserTyVar . noLoc) implicit_tvs
     newTvs tvs = HsQTvs
       { hsq_implicit  = []
       , hsq_explicit  = tvs
       , hsq_dependent = emptyNameSet }
     (univs, reqs, exis, provs, ty) = splitLHsPatSynTy body
 }}}

 In this particular example, all of `univs`, `reqs`, `exis`, and `provs`
 are `[]`. But `impls` is `[b,a]`, which causes `th_univs` to be `[b,a]` as
 well. In other words, that's why we see the incorrect `forall b a. forall.
 b -> T a` type signature.

 Is there a way to partition up `impls` to get `a` in `th_univs` and `b` in
 `th_exis`?

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


More information about the ghc-tickets mailing list