Stack is a tool to build Haskell projects and manage their dependencies. It uses the Cabal library but with a curated version of the Hackage repository called Stackage. Stack competes against Cabal's binary cabal-install and has been created as a result of the overall criticism about dependency problems.
How does stack-work Haskell?
Stack will manage your GHC installations and automatically select the appropriate compiler version for your project. The Cabal build system, a specification for defining Haskell packages, together with a library for performing builds. ... Stack defaults to using Stackage package sets to avoid dependency problems.
What does stack build do?
stack allows you to call out a specific component to be built, e.g. stack build mypackage:test:mytests will build the mytests component of the mypackage package. mytests must be a test suite component.