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
             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
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to