Search code examples
haskellcabalyesod

Haskell Environment


I recently finished the book "learnyouahaskell" and now I would like to apply my acquired knowledge by building a yesod application.

However I am not sure about how to get started.

There seems to be two options on how to set up a yesod project. One is with Stack, and the other is with cabal sandboxes.

But what are the differences (If any?) and the similarities between them? Does one count as best practice whereas the other doesn't?

The yesod quickstart suggests using stack, is this fine or should I use cabal sanbox?


Solution

  • There are actually three different packages that are being talked about here.

    1. cabal-install is the current stable binary to build your applications.
    2. stack was just released to the public recently. I believe it is trying to replace cabal-install as a better, more convenient tool. At the very least, it is showing the Haskell community a different way of something things.
    3. Cabal is the library that both cabal-install and stack are based off of.

    As for the differences between the first two tools.

    cabal-install is a mature application used nearly everywhere within the Haskell community (at least in open source, I have no idea what people are doing behind closed doors).

    stack is still a new (at least to the public) application used in some newer projects. Some more information can be found here. But some of the highlights are:

    • running stack build in a projects directory will install GHC (Haskell compiler) as well as the needed dependencies for the project.
    • stack, by default, runs off of stackage. Which is a curated version of hackage. Meaning you can expect the different packages to play nicely with each other. Leading to reproducible builds.
    • You can still fall back on hackage should you choose to.

    The great thing about these two applications is that they can be used by different people for the same project. If you decide you want to use cabal-install with sandboxes, and someone comes along and wants to help with your project, they can just add the files that stack needs and they can use stack while you continue to use cabal-install. Or vice-versa.

    here is one persons experience after using stack for the first time. They claim that it is a little bit easier to get started because there are a couple less steps required to get started. If nothing else, people highlight the pros and cons of each tool.

    Note: I'm still fairly new to Haskell, and have never actually used stack. I've actually been told to stay away from it unless building something in yesod.

    Edit: As stated in a comment under this answer, I believe I have mis-represented what people have told me about stack. The comments people have given me when I asked if I should switch over to stack were more along the lines of, If you are comfortable enough using cabal sandboxes, there is no reason to switch over to stack unless you are having issues.