StgExpr AST

Chris Nicholls chrisnicholls1 at
Thu Feb 10 11:09:39 CET 2011


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

Thanks for any help,


More information about the Glasgow-haskell-users mailing list