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