nicolas
nicolas

Reputation: 9805

Compiling a library with a newer set of dependency in haskell

Taking some not so old haskell project hdocs (last updated November 2020...).

Now I want to update its dependencies

#stack.yaml
flags: {}
packages:
- '.'
resolver:  nightly-2022-02-11
extra-deps:
- haddock-api-2.25.1

Then in both cases I get C pre-processing errors (!)

Building library for hdocs-0.5.5.0..

src/HDocs/Base.hs:69:5: error:
     error: function-like macro 'MIN_VERSION_haddock_library' is not defined
   |
69 | #if MIN_VERSION_haddock_library(1,8,0)
   |     ^
#if MIN_VERSION_haddock_library(1,8,0)
    ^
...

The error is not about some code but about the build process itself.

Am I missing something obvious in haskell ecosystem ?

Upvotes: 1

Views: 156

Answers (1)

duplode
duplode

Reputation: 34378

According to the relevant section of the Cabal User Guide, Cabal provides a MIN_VERSION macro "for each package depended on via build-depends. The hdocs.cabal currently on GitHub only specifies haddock-library in the conditional parts of build-depends, so it would be missing for anything above GHC 8.10. That being so, if we are to keep the cabal file organised in the same way, this specific error can be avoided by specifying the missing dependencies for GHC 9.0:

-- In the library section of hdocs.cabal:
  if impl(ghc == 9.0.*)
    build-depends:
      ghc == 9.0.*,
      haddock-api >= 2.25 && < 2.26,
      haddock-library == 1.10.*

Upvotes: 2

Related Questions