How to install a package using stack?

HaskellCabalCabal InstallPackage ManagementHaskell Stack

Haskell Problem Overview


Using cabal, I could install hakyll with the command:

cabal install hakyll

How can I do the same thing using stack?

Haskell Solutions


Solution 1 - Haskell

stack install hakyll

stack offers a curated set of packages that won't blow your machine up. If you want to check what packages are available, or exactly what version is supported, or on what version of GHC you can get it, check out https://www.stackage.org/.

For example, you can get hakyll 4.6.9.0 right now for both GHC 7.8.4 and GHC 7.10.1. Pretty neat. - source

EDIT: I forgot to mention, Yuan Wang's method works for getting the version of hakyll that is not curated into stackage. It's up to you what version you need.

Solution 2 - Haskell

add hakyll in stack.yaml generated by stack init or stack new

yaml file should look like:

flags: {}
packages:
  - '.'
extra-deps:
  - hakyll-4.7.1.0
resolver: lts-2.15

after that, run stack solver installs it

https://github.com/commercialhaskell/stack/wiki/stack.yaml

Solution 3 - Haskell

This documentation worked for me

On package.yaml add the library under dependencies, for example:

dependencies:
- base >= 4.7 && < 5
- hakyll # added here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBenView Question on Stackoverflow
Solution 1 - Haskelluser2913694View Answer on Stackoverflow
Solution 2 - HaskellYuan WangView Answer on Stackoverflow
Solution 3 - HaskellNestor TobonView Answer on Stackoverflow