I'm puzzled by a failure of my doctests on GHC-7.10.3 and older. The full error message is
Data/ByteString/Builder/HTTP/Chunked.hs:75:0:
error: missing binary operator before token "("
#if MIN_VERSION_base(4,8,0)
^
doctests: doctests: phase `C pre-processor' failed (exitcode = 1)
With GHC >= 8.0 the tests work as intended. In all cases I'm using doctest-0.15.0.
EDIT: What I gather from https://ghc.haskell.org/trac/ghc/ticket/10970 is that the MIN_VERSION_ macros were originally defined by cabal, but have been generated by GHC itself since v8.0. It appears that cabal v2.2 still produces the macros for GHC < 8.0 so e.g. new-build works but doctest bypasses cabal.
Can someone suggest a good workaround?
For those hit by this: another reason for the error is that if you have say #if MIN_VERSION_template_haskell(1,2,3) in your code, but forgot to add template-haskell to package dependencies in the .cabal file then you also get this error.
The fix is to add it to the dependencies :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With