haskellyamlghchaskell-stackhpack

Hpack or pre-processor platform info


I am using hpack+stack for a project and there is a hardcoded path (used for debugging, I don't want to do this properly) which are differs for mac os x and linux. Right now I have it on a gitignored file on it's own and that file differs between my workstations but I would much rather have the pre-processor deal with it.

Ideally I would like something equivalent to#ifdef __linux__, which dosnt work. I would even be happy with manipulating package.yaml to come up with -D compiler flags. Does hpack (which I think uses Data.Yaml) have this capability?


Solution

  • hpack does support this: hpack conditionals. It looks something like this:

    when:
      - condition: os(darwin)
      then:
        extra-lib-dirs: lib/darwin
      else:
        extra-lib-dirs: lib/linux