Skip to content

Packages and Stack Projects

A package is simply a collection of modules that constitute a project. Many authors publish their packages on Hackage. Some examples of packages published there are

  • base: The standard library.
  • array: All modules related to working with array, including Data.Array.
  • containers: A library of container types such as Sets and Maps (dictionaries).
  • mtl: The monad transformer library that provides the Reader, State, and Writer monads, and a few others.

There are 10,000s of packages available no Hackage. When searching for modules, types, type classes or functions on Hoogle, the default is that Hoogle searches the packages published on Hackage.

Most packages depend on other packages to be built. Pretty much every package depends on base because it contains the standard library. When using stack to build our own packages, we can add other packages to the dependency list of our own package. If the packages our package depends on are published on Hackage, then stack will download and compile those packages as part of the build process, and it will configure the compiler so it knows where to find the modules in those packages. If the packages are not on Hackage, then we need to tell stack where to find them. That can be a URL, a Github repository or a path to a directory on our computer if we want our package to depend on another package we have written. Here, we will discuss only how to add packages available on Hackage as dependencies. If you continue to program in Haskell beyond this course and find yourself writing code that depends on your own packages or on third-party packages not on Hackage, you will need to read the Haskell Stack Documentation to find out how to do tell stack where to find those packages.