[GHC] #14288: ScopedTypeVariables with nested foralls broken since 8.0.2

GHC ghc-devs at haskell.org
Tue Oct 3 11:37:05 UTC 2017


#14288: ScopedTypeVariables with nested foralls broken since 8.0.2
-------------------------------------+-------------------------------------
        Reporter:  MikolajKonarski   |                Owner:  RyanGlScott
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |
      Resolution:                    |             Keywords:
Operating System:  Linux             |         Architecture:  x86_64
 Type of failure:  GHC rejects       |  (amd64)
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Yes, this is awkward.

 When we instantiate a type signature, we currently instantiate only the
 outer foralls and context.  See `TcSigs.tcInstSig`.  The scoped type
 variables come from the `sig_inst_skols`.  Very similar story in
 `TcBinds.tcPolyCheck`.

 I suppose we can generalise this story.  Instead of having
 {{{
 data TcIdSigInst
   = TISI { ...
          , sig_inst_skols :: [(Name, TcTyVar)]
          , sig_inst_theta  :: TcThetaType
          ... }
 }}}
 I suppose we could have a list of pairs of those things:
 {{{
 data TcIdSigInst
   = TISI { ...
          , sig_inst_prefis :: [([(Name, TcTyVar)], TcThetaType)]
          ... }
 }}}
 Or maybe, more uniformly:
 {{{
 data TcIdSigInst
   = TISI { ...
          , sig_inst_prefis :: [SigInstSpec]
          ... }

 data SigInstSpec
   = SITyVar Name TcTyVar
   | SIPred  TcPredType
 }}}
 Then `tcInstType` might have type
 {{{
 tcInstType :: (...) -> Id -> TcM ([SigInstSpec], TcRhoType)
 }}}
 I think we could carry this through uniformly.  But I haven't tried.

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


More information about the ghc-tickets mailing list