Hi all,<br><br>We've been using to GHC-as-a-library to implement some parts of our project.<br>Our goal is to use ghc to extract necessary type information from Haskell modules.<br><br>Everything works fine until we attempt to collect the declared type class instances from a packaged haskell module, like List, Monad, etc.
<br>The program terminates with an error as follows, <br><br><br>getModuleInfo: instances for package module unimplemented<br><br><br><br><br>We manually trace into the source file /ghc/compiler/main/GHC.hs<br>and find the following snipet of code:
<br><br><br>getPackageModuleInfo :: HscEnv -> Module -> IO (Maybe ModuleInfo)<br>getPackageModuleInfo hsc_env mdl = do<br>#ifdef GHCI<br> (_msgs, mb_avails) <- getModuleExports hsc_env mdl<br> case mb_avails of
<br> Nothing -> return Nothing<br> Just avails -> do<br> eps <- readIORef (hsc_EPS hsc_env)<br> let <br> names = availsToNameSet avails<br> pte = eps_PTE eps<br> tys = [ ty | name <- concatMap availNames avails,
<br> Just ty <- [lookupTypeEnv pte name] ]<br> --<br> return (Just (ModuleInfo {<br> minf_type_env = mkTypeEnv tys,<br> minf_exports = names,<br> minf_rdr_env = Just $! nameSetToGlobalRdrEnv names (moduleName mdl),
<br> minf_instances = error "getModuleInfo: instances for package module unimplemented",<br> minf_modBreaks = emptyModBreaks <br> }))<br><br><br><br>It is clearly that the field mind_instances is not assigned to a proper value.
<br><br>Can someone kindly advise on how to implement the missing bit?<br>Or pointing out a workaround?<br><br>Thank you very much.<br><br>Best Regards,<br>Kenny Zhuo Ming Lu<br>