David Waern wrote:
2008/10/4 Thomas Schilling <[EMAIL PROTECTED]>:
'loadModule' now takes a ModSummary which should be enough to emulate
checkAndLoadModule with the new API.  It's in head and should be in
stable soon.

So how do I use this? Can you paste a snippet of code that, given a
list of files (or module names), typechecks them all in dependency
order?

Thanks,
David

ps. I tried this:

typecheckFiles :: [FilePath] -> Ghc [GhcModule]
typecheckFiles files = do

  -- load all argument files

  targets <- mapM (\f -> guessTarget f Nothing) files
  setTargets targets

  modgraph <- depanal [] False

  let getModFile = fromJust . ml_hs_file . ms_location
       mods'= [ (ms_mod modsum, ms_hspp_opts modsum, getModFile
modsum) | modsum <- modgraph ]

  -- typecheck the argument modules

  ghcMods <- forM mods' $ \(mod, flags, file) ->
    handleSourceError
        (\err -> do
           printExceptionAndWarnings err
           throwE ("Failed to check module: " ++ moduleString mod)) $
      do tc_mod <- loadModule =<< typecheckModule =<< parseModule =<<
getModSummary (moduleName mod)
         let Just renamed_src = renamedSource tc_mod
         return $ mkGhcModule (mod, file, (parsedSource tc_mod,
                                           renamed_src,
                                           typecheckedSource tc_mod,
                                           moduleInfo tc_mod))
                              flags

  return ghcMods

I think you're missing the topSortModuleGraph. For an (old) example, look in utils/ghctags. It is using checkAndLoadModule, but you should be able to replace that with parseModule/typecheckModule/loadModule.

Cheers,
        Simon

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to