rtytgat
rtytgat

Reputation: 497

Set compiler for 1 package in Haskell Stack

I'm trying to write a small web application fully in Haskell. I have 3 logical packages:

That last package is giving me trouble. I don't know how to structure the project so the other 2 packages can use it. I see 2 options at the moment:

  1. Each package has its own stack file and git repository. Import the shared package using an extra-deps git link. The problem with this approach is it means I have to push any change to the shared package to GitHub before I can test it out with the other packages. Also I'd have to build everything separately.
  2. Use a single repository with a single stack.yml file. I'd prefer this, since it keeps everything together and also assures all packages are using the same resolver. In this case I would list all the packages in the packages: option. However, the client needs to be compiled with GHCJS, not GHC, and I don't see an option in the documentation to override the compiler for 1 specific package.

Is there a way to make option 2 work? Or is there a better way to do this?

Upvotes: 0

Views: 69

Answers (1)

Emanuel Borsboom
Emanuel Borsboom

Reputation: 111

The recommended approach is to have two stack project files (e.g. stack-frontend.yaml using GHCJS and stack-backend.yaml using GHC), and then use the --stack-yaml argument to switch between them (e.g. use stack --stack-yaml=stack-frontend.yaml build to build the frontend, and stack --stack-yaml=stack-backend.yaml build to build the backend). Both stack-*.yaml files can include the shared servant API.

Upvotes: 1

Related Questions