Hi there, I am not hugely familiar with compilers or the particulars of GHC, but am interested in creating a few programs which manipulate Haskell source code in particular ways. Two things I would like to be able to do are:
- Swap every occurrence of a particular type for a different / dummy value of that type. - Find the line / column number of every place a value of a particular type is used >From compiling Haskell programs, it seems clear that GHC performs type checking, and when I get a compile error it is able extract line and column information about where I had the error, so it appears as if GHC is annotating the source with this information as it compiles. I am struggling to find a lot in the way of learning materials for GHC, but from trawling through the API documentation (I am using GHC version 7.4.2), it seems like I can generate an abstract syntax tree via the method: parseModule :: GhcMonad<http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:GhcMonad>m => ModSummary<http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:ModSummary>-> m ParsedModule<http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html#t:ParsedModule> My question is this: what combination of functions do I have to use to get not only an AST for my source, but an AST annotated with typing information and line / column number annotations for values within it? Also, as I am a bit of a newbie to this whole GHC API thing, any pointers to resources to learn more about it would be enormously appreciated. Thanks, Craig
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users