68

Using cabal, I could install hakyll with the command:

cabal install hakyll

How can I do the same thing using stack?

1

3 Answers 3

58
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.

2
  • 1
    what about installing packages that are only on hackage but not on stackage? Is the preferred method to install cabal-install or to download the tarball and stack install it?
    – mb21
    Commented Oct 25, 2016 at 8:02
  • 1
    I tried stack install accelerate-examples and got huge Error: While constructing the build plan, the following exceptions were encountered which goes recursively when trying to fix it. Couldn't even google what the stack build plans are.
    – Slaus
    Commented Feb 4, 2020 at 6:02
17

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

2
  • 16
    Probably worth adding that stack install hakyll all by itself is probably sufficient to get the desired result. Commented Jun 25, 2015 at 3:28
  • 1
    I think it's worth mentioning that this method is typically only done when the desired version of the package is not present in the selected snapshot. I believe the preferred method of package installation for a project is adding it to the *.cabal file's build-depends, or running stack install hakyll to test it out first.
    – JoL
    Commented Apr 24, 2017 at 16:17
5

This documentation worked for me

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

dependencies:
- base >= 4.7 && < 5
- hakyll # added here
1
  • 1
    For some reason I feel recent versions of GHC have gotten unnecessarily complicated. I used to be able to use cabal. Now I have to go through all of this mess (and more) to get my old programs to compile.
    – Shawn Eary
    Commented Sep 24, 2021 at 19:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.