
On Thu, Feb 10, 2011 at 1:09 PM, Chris Nicholls
Hello,
Is there a way to get access to the STG syntax tree of a program using the GHC api? i.e. a function that returns something of type `StgExpr' that can be used in a way similar to this:
example module = defaultErrorHandler defaultDynFlags $ do runGhc (Just libdir) $ do dflags <- getSessionDynFlags setSessionDynFlags dflags target <- guessTarget targetFile Nothing setTargets [target] load LoadAllTargets modSum <- getModSummary $ mkModuleName module p <- parseModule modSum t <- typecheckModule p d <- desugarModule t c <- return $ coreModule d s <- coreToStg c return s
I've written Haskell to Javascript translator using GHC API. And I've ended with the following code to access STG: https://github.com/sviperll/ghcjs/blob/master/src/Compiler/Main.hs -- Victor Nazarov