[GHC] #15613: GHCi command, tracing steps of instance resolution for Constraint or expression

GHC ghc-devs at haskell.org
Tue Sep 11 17:49:33 UTC 2018


#15613: GHCi command, tracing steps of instance resolution for Constraint or
expression
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  lowest            |            Milestone:
       Component:  GHCi              |              Version:
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #15610            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 > Plus, remember it's a tree: a goal may lead to multiple sub-goals...

 Yes.

 Should I make a GHC proposal or is it minimal enough to decide here? I
 started implementing it: Where do I tap into the current machinery and how
 best to pass the tree back?

 It took me a while to be able to find the class being solved, by using
 `mkClassPred clas tys` in definitions like
 [https://hackage.haskell.org/package/ghc-8.4.3/docs/src/TcInteract.html#runSolverPipeline
 runSolverPipeline],
 [https://hackage.haskell.org/package/ghc-8.4.3/docs/src/InstEnv.html#memberInstEnv
 matchInstEnv] ..

 {{{#!hs
   run_pipeline ((stg_name,stg):stgs) (ContinueWith ct)
     = do { traceTcS ("runStage " ++ stg_name ++ " {")
                     (text "workitem   = " <+> ppr ct)
          ; res <- stg ct

          ; let current :: PredType
                current = mkClassPred clas tys

          ; traceTcS ("end stage " ++ stg_name ++ " }") empty
          ; run_pipeline stgs res }
 }}}

 and then calling `hscTcExpr` from ''UI''. I'm sure there is a better way
 but that's how I got started

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


More information about the ghc-tickets mailing list