Home > Enterprise >  Compiling a library with a newer set of dependency in haskell
Compiling a library with a newer set of dependency in haskell

Time:02-12

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

  • If I build it with the original Stack file, everything is fine. And I can still build upon it on my own projects with the other libraries of that LTS which works well together. Reproducibl-ish build is good.

Now I want to update its dependencies

  • if I build it (after ghcup set ghc 9.0.2) with cabal v1-build I get nonsense about "fail backjumping" and "private dependencies"

  • If I either

    • cabal v2-build (after ghcup set ghc 9.0.2) and let it think hard
    • or if I build it using stack build
#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 ?

CodePudding user response:

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.*
  • Related