preprocessor - Conditional Compilation inside Literate Haskell -
i have literate haskell file , want use conditional compilation. use bird style of literate programming. following code not work.
> #if min_version_base(4,6,0) > import control.exception > #endif i need solution cabal 1.14.0
edit:
cpphs has option --unlit unlits literate sourcecode, don't know how pass option cpphs in cabal.
as @kosmikus points out, can put c preprocessor directives outside > or \begin{code} , work expected – if not interfere processing of non-code parts of literal code.
you cannot use c preprocessor directives bird-style literate programming, unlitting step replaces > space, have no chance # first column. can verify passing -keep-tmp-files ghc , checkout generated .lpp file.
you can resort \begin{code}...\end{code} blocks both, if mix them them >-style lines of code, keep space in mind , add lines wrapped in \begin{code}...\end{code}:
> {-# language cpp #-} literal comment \begin{code} #if min_version_base(4,6,0) import control.exception #endif \end{code} > main = return ()
Comments
Post a Comment