---------- Forwarded message ---------- From: Vivian McPhail <haskell.vivian.mcph...@gmail.com> Date: 22 June 2011 17:17 Subject: #4459: Loading Names and Types via GHC To: cvs-...@haskell.org
Hi, I can successfully set up GHC and compile a module, say 'X.hs'. <quote> dynload :: Symbol -> ModuleName -> DynType (Either [String] DynamicHValue) dynload sym m = do liftGhc $ GHC.setTargets [GHC.Target (GHC.TargetModule m) True Nothing] res <- liftGhc $ GHC.load GHC.LoadAllTargets case res of GHC.Failed -> return $ Left ["failed to load module: "++(moduleNameString m)] GHC.Succeeded -> do </quote> I'm failing to load the symbol, with a "not in scope" error: <quote> nms <- liftGhc $ GHC.parseName sym case nms of [] -> return $ Left ["could not find name: <<" ++sym++">>"] (n:_) -> do </quote> I am attempting to then load the `HValue` and `Type` of a given variable: <quote> mod <- liftGhc $ GHC.findModule m Nothing Just mod_info <- liftGhc $ GHC.getModuleInfo mod Just ty <- liftGhc $ GHC.modInfoLookupName mod_info n hval <- withSession $ \hsc_env -> liftIO $ getHValue hsc_env n return $ Right (DynamicHValue ty hval) </quote> However, I am not sure how to create a `Name` from a String that is the variable name. How do I do that? I can get a list of names, but I get an error "Not in scope: `<var_name>` Also, what is the difference between a `Type` and a `TyThing` and which should I be using? Vivian
_______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs