rem*_*rem 1 preprocessor haskell
解析包含#define和的haskell源文件时#if,parseFileContentsWithMode会混淆并抛出有关散列的错误.我想包括MagicHash和CPP扩展名列表(extns见下文),但没有奏效.我无法真正更改源文件,因为它们有很多.
getModule extns filePath program = fromParseResult $ parseFileContentsWithMode mode program
where
bangPatternsExt = map parseExtension extns
mode = ParseMode filePath Haskell2010 bangPatternsExt False False
Run Code Online (Sandbox Code Playgroud)
解析器失败了:
#if __GLASGOW_HASKELL__ >= 612
instance Lift ModName where
lift = lift . modString
Run Code Online (Sandbox Code Playgroud)
Haskell-src-exts本身不支持CPP(在GitHub问题跟踪器中没有问题,但在http://trac.haskell.org/haskell-src-exts/ticket/27上有一个旧问题.).
您可以查看haskell-src-exts解析模块的解决方案或解决方法,其中CPP无法解决方法(使用cpphs).
还有一个名为hse-cpp的软件包(https://hackage.haskell.org/package/hse-cpp),看起来它可以为你运行cpphs,但是我还没有使用它,它看起来不像得到更新.