Skip to content

6. Installed package databases

Time to take a short break from hands-on examples and discuss a little architecture. Stack has the concept of multiple databases.

A database consists of a GHC package database (which contains the compiled version of a library), executables, and a few other things as well. To give you an idea, the contents of the parent directory of the stack path --local-pkg-db directory are the directories:

bin
doc
lib
pkgdb

Databases in Stack are layered. For example, the database listing we just gave is called a local database (also known as a mutable database). That is layered on top of a snapshot database (also known as a write-only database). The snapshot database contains the libraries and executables that are considered to be immutable. Finally, GHC itself ships with a number of libraries and executables, also considered to be immutable, which forms the global database.

To get a quick idea of this, we can look at the output of the stack exec -- ghc-pkg list command in our helloworld project:

<stack path --global-pkg-db directory>
    Cabal-3.6.3.0
    Win32-2.12.0.1