[GHC] #12860: GeneralizedNewtypeDeriving + MultiParamTypeClasses sends typechecker into an infinite loop

GHC ghc-devs at haskell.org
Mon Apr 16 13:25:08 UTC 2018


#12860: GeneralizedNewtypeDeriving + MultiParamTypeClasses sends typechecker into
an infinite loop
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |             Keywords:  FunDeps,
      Resolution:                    |  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Hm. I tried to use `checkValidInstance`, but there's a big problem: its
 type signature is not very amenable to being put into
 `simplifyInstanceContexts`. It is
 [http://git.haskell.org/ghc.git/blob/fea04defa64871caab6339ff3fc5511a272f37c7:/compiler/typecheck/TcValidity.hs#l1303
 currently]:

 {{{#!hs
 checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type
                    -> TcM ([TyVar], ThetaType, Class, [Type])
 }}}

 There are two awkward things about this:

 1. It expects an `LHsSigType GhcRn` argument, but this isn't available in
 `simplifyInstanceContexts`. (However, `checkValidInstance` only uses this
 to get a `SrcSpan`, so perhaps this can be changed to just be a `SrcSpan`
 argument.)
 2. A more awkward sticking point is that `checkValidInstance` expects a
 `Type` as an argument. This is because it then proceeds to split it with
 `tcSplitSigmaTy` (and returns the resulting tyvars and theta). However, in
 `simplifyInstanceContexts`, our instance type is already "pre-split" (that
 is, we already have the tyvars, theta, class, and class argument types
 lying around).

    What's worse, I can't just change the `Type` argument and replace it
 with the constituent `[TyVar]`, `ThetaType`, etc., since
 `checkValidInstance` passes that `Type` wholesale to `checkAmbiguity`. So
 I don't know what to do here.

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


More information about the ghc-tickets mailing list