preprocessor- Remove cpp annotations to get the source ready for static analysis.

Copyright(c) Carlo Nucera, 2016
Safe HaskellNone



This library preprocesses the cpp directives in haskell source code (a task not usually done by parsing libraries), to prepare it for static analysis, e.g. with haskell-src-exts.

The design of the library is guided by two principles:

  • Line numbering with the original file should be preserved: if a line isn't related to cpp preprocessing, it conserves its position. This is done to make eventual failings with the parsing library easier to locate.
  • It should offer a very simple API, shielding the user from the understandings of how cabal options are passed around, and trying to automatically find all the required information in the project. The user is expected to use only the two functions in this module.

Currently this tool requires the library to have been built with stack (it searches for some files generated in .stack-work). In the future I'll probably lift this restriction (if you need it before, please open a ticket). The files marked as internal are exported for documentation purposes only.



getLibExposedModulesPath :: CabalFilePath -> IO [FilePath] Source #

Given the path to the cabal file, this returns the paths to all the exposed modules of the library section.

preprocessFile :: FilePath -> IO String Source #

Given the path to a file in a stack-build project, returns the content of the preprocessed file. The line numbering of the original file is preserved.