diff --git a/doc/other_resources.md b/doc/other_resources.md
index 5935efba0f..31887f32b3 100644
--- a/doc/other_resources.md
+++ b/doc/other_resources.md
@@ -17,3 +17,10 @@ There are lots of resources available for learning more about Stack:
* The [haskell-stack tag on Stack Overflow](http://stackoverflow.com/questions/tagged/haskell-stack)
* [Another getting started with Stack tutorial](http://seanhess.github.io/2015/08/04/practical-haskell-getting-started.html)
* [Why is Stack not Cabal?](https://www.fpcomplete.com/blog/2015/06/why-is-stack-not-cabal)
+
+Package description format specifications supported by Stack:
+
+* Cabal's: a
+ [Cabal file](https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html)
+* Hpack's: a
+ [`package.yaml` file](https://github.com/sol/hpack?tab=readme-ov-file#documentation)
diff --git a/doc/tutorial/building_existing_projects.md b/doc/tutorial/building_existing_projects.md
index da94a6b814..6bdbf96030 100644
--- a/doc/tutorial/building_existing_projects.md
+++ b/doc/tutorial/building_existing_projects.md
@@ -1,6 +1,6 @@
-# 3. Building existing projects
+# 5. Building existing projects
Alright, enough playing around with simple projects. Let's take an open source
package and try to build it. We'll be ambitious and use
diff --git a/doc/tutorial/building_your_project.md b/doc/tutorial/building_your_project.md
index 877a53bf09..57f67820c7 100644
--- a/doc/tutorial/building_your_project.md
+++ b/doc/tutorial/building_your_project.md
@@ -1,6 +1,6 @@
-# 2. Building your project
+# 4. Building your project
The [`stack build`](../commands/build_command.md) command is the heart of Stack.
It is the engine that powers building your code, testing it, getting
diff --git a/doc/tutorial/cabal_flags_and_ghc_options.md b/doc/tutorial/cabal_flags_and_ghc_options.md
index 2ffa447337..87eacde79d 100644
--- a/doc/tutorial/cabal_flags_and_ghc_options.md
+++ b/doc/tutorial/cabal_flags_and_ghc_options.md
@@ -1,6 +1,6 @@
-# 8. Cabal flags and GHC options
+# 10. Cabal flags and GHC options
There are two common ways to alter how a package will install: with Cabal flags
and with GHC options.
diff --git a/doc/tutorial/executing_commands.md b/doc/tutorial/executing_commands.md
index 11a61032c8..0a0fcf34c7 100644
--- a/doc/tutorial/executing_commands.md
+++ b/doc/tutorial/executing_commands.md
@@ -1,6 +1,6 @@
-# 10. Executing commands
+# 12. Executing commands
We've already used `stack exec` multiple times in this guide. As you've likely
already guessed, it allows you to run executables, but with a slightly modified
diff --git a/doc/tutorial/hello_world_example.md b/doc/tutorial/hello_world_example.md
index 3dd0c5173b..1e80c011cc 100644
--- a/doc/tutorial/hello_world_example.md
+++ b/doc/tutorial/hello_world_example.md
@@ -331,362 +331,3 @@ Completed 2 action(s).
~~~
Having build the test suite executable, Stack then automatically runs it.
-
-## Inner workings of Stack
-
-Let's look at the `helloworld` example in more detail to understand better how
-Stack works.
-
-The files in the project are set out below. Click :material-plus-circle: to
-learn more about each file:
-
-~~~shell
-.
-├── app
-│ └── Main.hs # (1)!
-├── src
-│ └── Lib.hs # (2)!
-├── test
-│ └── Spec.hs # (3)!
-│
-├── .gitignore # (4)!
-├── CHANGELOG.md # (5)!
-├── LICENSE # (6)!
-├── README.md # (7)!
-│
-├── package.yaml # (8)!
-├── helloworld.cabal # (9)!
-├── Setup.hs # (10)!
-└── stack.yaml # (11)!
-~~~
-
-1. The Haskell source code for the executable (application).
-
- As your project develops you can add further source code files to the `app`
- directory.
-
-2. The executable uses a library. The Haskell source code for the library.
-
- As your project develops you can add further source code files to the `src`
- directory.
-
-3. The package has a test suite executable. The Haskell source code for the
- test suite.
-
- As your project develops you can add further source code files to the `test`
- directory.
-
-4. A text file used to configure the Git tool to ignore certain files. Does not
- affect the build.
-
-5. A text file in the Markdown format in which changes to the project can be
- documented. Does not affect the build.
-
-6. A text file used to document the copyright applicable to the project's files
- and the licence for the use of those files. Does not affect the build.
-
-7. A text file in the Markdown format which is intended to be read by users of
- the project. Does not affect the build.
-
-8. A file describing the package in the Hpack format. See further below.
-
-9. A file describing the package in the Cabal format. See further below.
-
-10. A Haskell source file which is a component of the Cabal build system. See
- further below.
-
-11. A text file in the YAML format, containing Stack's project-level
- configuration. See further below.
-
-The files of most interest here are `package.yaml`, `helloworld.cabal`,
-`Setup.hs` and `stack.yaml`.
-
-### `package.yaml`
-
-Each package contains a file that describes the package. Stack uses the Cabal
-build system and that system uses a Cabal file named after the package (such as
-`helloworld.cabal`) to describe the package.
-
-However, Stack's preferred package description format is the
-[Hpack](https://github.com/sol/hpack) format.
-
-The `package.yaml` file describes the package in the Hpack format.
-
-If a `package.yaml` file is present, Stack will use its built-in Hpack
-functionality to create a Cabal file.
-
-??? question "What is covered by a package description?"
-
- A package description includes information such as the package name and
- version, and the package's *components*. A package can have an optional
- main library component and optional named sub-library components. It can
- also have optional executable components, test suite components and
- benchmark components. The description identifies other packages on which
- those components depend.
-
- The
- [Cabal User Guide](https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html)
- is the definitive reference for the Cabal package description format.
-
- The [Hpack](https://github.com/sol/hpack#quick-reference) documentation
- is the reference for the Hpack package description format.
-
-??? question "What are the contents of the `package.yaml` file?"
-
- The contents of the `package.yaml` file are described below, using
- additional YAML comments:
-
- ~~~yaml
- # The name of the package:
- name: helloworld
- # The version of the package:
- version: 0.1.0.0
- # The GitHub repository for the package:
- github: "githubuser/helloworld"
- # The licence for the use of the package's files:
- license: BSD-3-Clause
- # The author of the package:
- author: "Author name here"
- # The email address to contact the maintainer of the package:
- maintainer: "example@example.com"
- # The copyright for the package's files:
- copyright: "2024 Author name here"
-
- # Extra files to be distributed with the source files of the package:
- extra-source-files:
- - README.md
- - CHANGELOG.md
-
- # Metadata used when publishing your package
- # synopsis: Short description of your package
- # category: Web
-
- # To avoid duplicated efforts in documentation and dealing with the
- # complications of embedding Haddock markup inside cabal files, it is
- # common to point users to the README.md file.
- description: Please see the README on GitHub at
-
-
- # Dependencies applicable to all components:
- dependencies:
- - base >= 4.7 && < 5
-
- # GHC options common to all components:
- ghc-options:
- # These GHC flags affect which warnings GHC will emit:
- - -Wall
- - -Wcompat
- - -Widentities
- - -Wincomplete-record-updates
- - -Wincomplete-uni-patterns
- - -Wmissing-export-lists
- - -Wmissing-home-modules
- - -Wpartial-fields
- - -Wredundant-constraints
-
- # The main (unnamed) library component of the package:
- library:
- # Directories containing source files:
- source-dirs: src
-
- # The executable components of the package:
- executables:
- # The executable component named 'helloworld-exe':
- helloworld-exe:
- # The source file exporting the 'main' function:
- main: Main.hs
- # Directories containing source files:
- source-dirs: app
- # GHC options applicable to the component:
- ghc-options:
- # Link the program with the 'threaded' version of GHC's runtime system:
- - -threaded
- # Make all of GHC's runtime system (RTS) options available:
- - -rtsopts
- # Compile so as to use simultaneous threads when running the program,
- # based on how many processors are in the machine.
- - -with-rtsopts=-N
- # Dependencies applicable to the component:
- dependencies:
- # The main library of the package:
- - helloworld
-
- # The test suite components of the package. Test suites have keys in common
- # with executables:
- tests:
- # The test suite component named 'helloworld-test':
- helloworld-test:
- main: Spec.hs
- source-dirs: test
- ghc-options:
- - -threaded
- - -rtsopts
- - -with-rtsopts=-N
- dependencies:
- - helloworld
- ~~~
-
-### `helloworld.cabal`
-
-The `helloworld.cabal` file is updated automatically as part of the
-`stack build` process and should not be modified.
-
-??? question "What are the contents of the `helloworld.cabal` file?"
-
- The contents of the `helloworld.cabal` file are described below, using
- additional Cabal file comments:
-
- ~~~text
- -- The version of the Cabal package description format specification:
- cabal-version: 2.2
-
- -- This file has been generated from package.yaml by hpack version 0.37.0.
- --
- -- see: https://github.com/sol/hpack
-
- -- The name of the package:
- name: helloworld
- -- The version of the package:
- version: 0.1.0.0
- -- The description of the package:
- description: Please see the README on GitHub at
-
- -- A URL for the package:
- homepage: https://github.com/githubuser/helloworld#readme
- -- A URL for bug reports for the package:
- bug-reports: https://github.com/githubuser/helloworld/issues
- -- The author of the package:
- author: Author name here
- -- The email address to contact the maintainer of the package:
- maintainer: example@example.com
- -- The copyright for the package's files:
- copyright: 2024 Author name here
- -- The licence for the use of the package's files:
- license: BSD-3-Clause
- -- The file documenting the terms of the licence:
- license-file: LICENSE
- -- The Cabal system build type of the package:
- build-type: Simple
- -- Extra files to be distributed with the source files of the package:
- extra-source-files:
- README.md
- CHANGELOG.md
-
- -- The respository for the package:
- source-repository head
- type: git
- location: https://github.com/githubuser/helloworld
-
- -- The main (unnamed) library component of the package:
- library
- -- The modules that the library exposes:
- exposed-modules:
- Lib
- -- The other modules of the compoment:
- other-modules:
- Paths_helloworld
- -- Automatically generated modules of the component:
- autogen-modules:
- Paths_helloworld
- -- Directories containing source files:
- hs-source-dirs:
- src
- -- GHC options applicable to the component. In this case, they are flags
- -- that affect which warnings GHC will emit:
- ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates
- -Wincomplete-uni-patterns -Wmissing-export-lists
- -Wmissing-home-modules -Wpartial-fields
- -Wredundant-constraints
- -- Dependencies applicable to the building of the component:
- build-depends:
- base >=4.7 && <5
- -- The applicable version of the Haskell language:
- default-language: Haskell2010
-
- -- The executable 'helloworld-exe' component of the package. Executable
- -- components have fields in common with library components:
- executable helloworld-exe
- -- The source file exporting the 'main' function:
- main-is: Main.hs
- other-modules:
- Paths_helloworld
- autogen-modules:
- Paths_helloworld
- hs-source-dirs:
- app
- -- GHC options applicable to the component. In this case, they include
- -- flags that affect GHC's runtime system (RTS).
- ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates
- -Wincomplete-uni-patterns -Wmissing-export-lists
- -Wmissing-home-modules -Wpartial-fields
- -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
- build-depends:
- base >=4.7 && <5
- , helloworld
- default-language: Haskell2010
-
- -- The test suite 'helloworld-test' component of the package. Test suite
- -- components have fields in common with executable components:
- test-suite helloworld-test
- -- The type of the test suite:
- type: exitcode-stdio-1.0
- main-is: Spec.hs
- other-modules:
- Paths_helloworld
- autogen-modules:
- Paths_helloworld
- hs-source-dirs:
- test
- ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates
- -Wincomplete-uni-patterns -Wmissing-export-lists
- -Wmissing-home-modules -Wpartial-fields
- -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
- build-depends:
- base >=4.7 && <5
- , helloworld
- default-language: Haskell2010
- ~~~
-
-### `Setup.hs`
-
-The `Setup.hs` file is a component of the Cabal build system.
-
-Technically, it is not needed by Stack, but it is considered good practice to
-include it. The file we're using is boilerplate:
-
-~~~haskell
-import Distribution.Simple
-main = defaultMain
-~~~
-
-### `stack.yaml`
-
-Stack requires a Stack project-level configuration file for every project.
-`stack.yaml` is that file. The contents of the file define project-specific
-options and non-project-specific options that apply to the project.
-
-The contents of the file include comments beginning `#`. Ignoring those
-comments, the contents will look something like this:
-
-~~~yaml
-snapshot:
- url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/31.yaml
-packages:
-- .
-~~~
-
-The key [`snapshot`](../configure/yaml/project.md#snapshot) is a
-project-specific configuration option. Its value tells Stack *how* to build your
-package: which GHC version to use, which versions of package dependencies to
-use, and so on. Our value here says to use
-[LTS Haskell 22.31](https://www.stackage.org/lts-22.31), which implies GHC 9.6.6
-(which is why `stack build` installs that version of GHC if it is not already
-available to Stack). There are a number of values you can use for `snapshot`,
-which we'll cover later.
-
-The key [`packages`](../configure/yaml/project.md#packages) is another
-project-specific configuration option. Its value tells Stack which project
-packages, located locally, to build. In our simple example, we have only a
-single project package, located in the same directory, so '`.`' suffices.
-However, Stack has powerful support for multi-package projects, which we'll
-describe as this guide progresses.
diff --git a/doc/tutorial/installed_package_databases.md b/doc/tutorial/installed_package_databases.md
index e9ff90dec3..43363c2d03 100644
--- a/doc/tutorial/installed_package_databases.md
+++ b/doc/tutorial/installed_package_databases.md
@@ -1,6 +1,6 @@
-# 4. Installed package databases
+# 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*.
diff --git a/doc/tutorial/locations_used_by_stack.md b/doc/tutorial/locations_used_by_stack.md
index 8b408cbd77..0bfdf3e46e 100644
--- a/doc/tutorial/locations_used_by_stack.md
+++ b/doc/tutorial/locations_used_by_stack.md
@@ -1,6 +1,6 @@
-# 9. Locations used by Stack
+# 11. Locations used by Stack
Generally, you don't need to worry about where Stack stores various files. But
some people like to know this stuff. That's when the `stack path` command is
diff --git a/doc/tutorial/multi-package_projects.md b/doc/tutorial/multi-package_projects.md
index fd3fbd705f..2852bf2cff 100644
--- a/doc/tutorial/multi-package_projects.md
+++ b/doc/tutorial/multi-package_projects.md
@@ -1,6 +1,6 @@
-# 7. Multi-package projects
+# 9. Multi-package projects
Until now, everything we have done with Stack has used a single-package project.
However, Stack's power truly shines when you're working on multi-package
diff --git a/doc/tutorial/package_description.md b/doc/tutorial/package_description.md
new file mode 100644
index 0000000000..2a01a3cb04
--- /dev/null
+++ b/doc/tutorial/package_description.md
@@ -0,0 +1,402 @@
+
+
+# 2. Package description
+
+Let us begin to look at the `helloworld` example in more detail to understand
+better how Stack works.
+
+The contents of the project directory are set out below. Click
+:material-plus-circle: to learn more about each file or directory:
+
+~~~shell
+.
+├── .stack-work # (1)!
+│ └── ...
+│
+├── app
+│ └── Main.hs # (2)!
+├── src
+│ └── Lib.hs # (3)!
+├── test
+│ └── Spec.hs # (4)!
+│
+├── .gitignore # (5)!
+├── CHANGELOG.md # (6)!
+├── LICENSE # (7)!
+├── README.md # (8)!
+│
+├── package.yaml # (9)!
+├── helloworld.cabal # (10)!
+├── Setup.hs # (11)!
+│
+└── stack.yaml # (12)!
+~~~
+
+1. The Stack work directory for the project and the project package.
+
+ Stack work directories are ones in which Stack stores files created during
+ the build process. A product of the build - does not affect the build (other
+ than to avoid rebuilding things unnecessarily).
+
+2. The Haskell source code for the executable (application).
+
+ As your project develops you can add further source code files to the `app`
+ directory.
+
+3. The executable uses a library. The Haskell source code for the library.
+
+ As your project develops you can add further source code files to the `src`
+ directory.
+
+4. The package has a test suite executable. The Haskell source code for the
+ test suite.
+
+ As your project develops you can add further source code files to the `test`
+ directory.
+
+5. A text file used to configure the Git tool to ignore certain files. Does not
+ affect the build.
+
+6. A text file in the Markdown format in which changes to the project can be
+ documented. Does not affect the build.
+
+7. A text file used to document the copyright applicable to the project's files
+ and the licence for the use of those files. Does not affect the build.
+
+8. A text file in the Markdown format which is intended to be read by users of
+ the project. Does not affect the build.
+
+9. A file describing the package in the Hpack format. See further below.
+
+10. A file describing the package in the Cabal format. See further below.
+
+11. A Haskell source file which is a component of the Cabal build system. See
+ further below.
+
+12. A text file in the YAML format, containing Stack's project-level
+ configuration. See the next part of this guide to getting started.
+
+The files of most interest here are `package.yaml` and `helloworld.cabal`. We
+will also explain the `Setup.hs` file.
+
+## Package description formats
+
+Each package contains a file that describes the package. It is located in the
+package's root directory.
+
+??? question "What is covered by a package description?"
+
+ A package description includes information such as the package name and
+ version, and the package's *components*. A package can have an optional
+ main library component and optional named sub-library components. It can
+ also have optional executable components, test suite components and
+ benchmark components. The description identifies other packages on which
+ those components depend.
+
+Stack is aware of two different formats of package description, and both files
+may be present in the package's root directory:
+
+
+
+- :material-package-variant:{ .lg .middle } __Cabal: A Cabal file__
+
+ Used directly by the Cabal build system.
+
+ Unique but simple syntax.
+
+ Named after the package (eg `helloworld.cabal`).
+
+ If no `package.yaml` file, used directly by Stack.
+
+ ---
+
+ Specified by the Cabal project:
+
+ [:octicons-arrow-right-24: Learn more](https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html)
+
+- :material-package-variant-plus:{ .lg .middle } __Hpack: a package.yaml file__
+
+ Used by Stack to create a Cabal file.
+
+ YAML syntax.
+
+ Named `package.yaml`.
+
+ Stack's preferred format. If present, used by Stack.
+
+ ---
+
+ Specified by the Hpack project:
+
+ [:octicons-arrow-right-24: Learn more](https://github.com/sol/hpack?tab=readme-ov-file#documentation)
+
+
+
+??? question "I use the Hpack format. Should I also check-in a Cabal file to my repository?"
+
+ Yes. This helps people who do not use Stack or the Hpack tool separately.
+
+## `package.yaml`
+
+The `package.yaml` file describes the package in the
+[Hpack format](https://github.com/sol/hpack?tab=readme-ov-file#documentation).
+
+If a `package.yaml` file is present, Stack will use its built-in Hpack
+functionality to create a Cabal file.
+
+??? question "What are the contents of the `package.yaml` file?"
+
+ The contents of the `package.yaml` file for the `helloworld` example are
+ described below, using additional YAML comments:
+
+ ~~~yaml
+ # The name of the package:
+ name: helloworld
+ # The version of the package:
+ version: 0.1.0.0
+ # The GitHub repository for the package (optional):
+ github: "githubuser/helloworld"
+ # The licence for the use of the package's files (optional):
+ license: BSD-3-Clause
+ # The author of the package (optional):
+ author: "Author name here"
+ # The email address to contact the maintainer of the package (optional):
+ maintainer: "example@example.com"
+ # The copyright for the package's files (optional):
+ copyright: "2024 Author name here"
+
+ # Extra files (if any) to be distributed with the source files of the
+ # package:
+ extra-source-files:
+ - README.md
+ - CHANGELOG.md
+
+ # Metadata used when publishing your package
+ # synopsis: Short description of your package
+ # category: Web
+
+ # To avoid duplicated efforts in documentation and dealing with the
+ # complications of embedding Haddock markup inside cabal files, it is
+ # common to point users to the README.md file.
+ description: Please see the README on GitHub at
+
+
+ # Dependencies applicable to all components:
+ dependencies:
+ - base >= 4.7 && < 5
+
+ # GHC options (if any) common to all components:
+ ghc-options:
+ # These GHC flags affect which warnings GHC will emit:
+ - -Wall
+ - -Wcompat
+ - -Widentities
+ - -Wincomplete-record-updates
+ - -Wincomplete-uni-patterns
+ - -Wmissing-export-lists
+ - -Wmissing-home-modules
+ - -Wpartial-fields
+ - -Wredundant-constraints
+
+ # The main (unnamed) library component of the package (if it has one):
+ library:
+ # Directories containing source files:
+ source-dirs: src
+
+ # The executable components of the package (if it has any):
+ executables:
+ # The executable component named 'helloworld-exe':
+ helloworld-exe:
+ # The source file exporting the 'main' function:
+ main: Main.hs
+ # Directories containing source files:
+ source-dirs: app
+ # GHC options applicable to the component:
+ ghc-options:
+ # Link the program with the 'threaded' version of GHC's runtime system:
+ - -threaded
+ # Make all of GHC's runtime system (RTS) options available:
+ - -rtsopts
+ # Compile so as to use simultaneous threads when running the program,
+ # based on how many processors are in the machine.
+ - -with-rtsopts=-N
+ # Dependencies applicable to the component:
+ dependencies:
+ # The main library of the package:
+ - helloworld
+
+ # The test suite components of the package (if it has any). Test suites have
+ # keys in common with executables:
+ tests:
+ # The test suite component named 'helloworld-test':
+ helloworld-test:
+ main: Spec.hs
+ source-dirs: test
+ ghc-options:
+ - -threaded
+ - -rtsopts
+ - -with-rtsopts=-N
+ dependencies:
+ - helloworld
+ ~~~
+
+??? question "What are the contents of a minimal `package.yaml` file?"
+
+ For a package `my-package-0.1.0.0` with a main library, an executable
+ named `my-program`, and a dependency only on the `base` package, its
+ `package.yaml` file could be as simple as the one below:
+
+ ~~~yaml
+ package: my-package
+ version: 0.1.0.0
+ dependencies:
+ - base
+ library:
+ source-dirs: src
+ executables:
+ my-program:
+ main: Main.hs
+ source-dirs: app
+ ghc-options:
+ - -threaded
+ - -rtsopts
+ - -with-rtsopts=-N
+ dependencies:
+ - my-package
+ ~~~
+
+## `helloworld.cabal`
+
+In the case of the `helloworld` example, the `helloworld.cabal` file is updated
+automatically as part of the `stack build` process and should not be modified.
+
+If the `package.yaml` file were deleted, Stack would use the Cabal file
+directly.
+
+??? question "What are the contents of the `helloworld.cabal` file?"
+
+ The contents of the `helloworld.cabal` file are described below, using
+ additional Cabal file comments:
+
+ ~~~text
+ -- The version of the Cabal package description format specification:
+ cabal-version: 2.2
+
+ -- This file has been generated from package.yaml by hpack version 0.37.0.
+ --
+ -- see: https://github.com/sol/hpack
+
+ -- The name of the package:
+ name: helloworld
+ -- The version of the package:
+ version: 0.1.0.0
+ -- The description of the package:
+ description: Please see the README on GitHub at
+
+ -- A URL for the package:
+ homepage: https://github.com/githubuser/helloworld#readme
+ -- A URL for bug reports for the package:
+ bug-reports: https://github.com/githubuser/helloworld/issues
+ -- The author of the package:
+ author: Author name here
+ -- The email address to contact the maintainer of the package:
+ maintainer: example@example.com
+ -- The copyright for the package's files:
+ copyright: 2024 Author name here
+ -- The licence for the use of the package's files:
+ license: BSD-3-Clause
+ -- The file documenting the terms of the licence:
+ license-file: LICENSE
+ -- The Cabal system build type of the package:
+ build-type: Simple
+ -- Extra files to be distributed with the source files of the package:
+ extra-source-files:
+ README.md
+ CHANGELOG.md
+
+ -- The respository for the package:
+ source-repository head
+ type: git
+ location: https://github.com/githubuser/helloworld
+
+ -- The main (unnamed) library component of the package:
+ library
+ -- The modules that the library exposes:
+ exposed-modules:
+ Lib
+ -- The other modules of the compoment:
+ other-modules:
+ Paths_helloworld
+ -- Automatically generated modules of the component:
+ autogen-modules:
+ Paths_helloworld
+ -- Directories containing source files:
+ hs-source-dirs:
+ src
+ -- GHC options applicable to the component. In this case, they are flags
+ -- that affect which warnings GHC will emit:
+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates
+ -Wincomplete-uni-patterns -Wmissing-export-lists
+ -Wmissing-home-modules -Wpartial-fields
+ -Wredundant-constraints
+ -- Dependencies applicable to the building of the component:
+ build-depends:
+ base >=4.7 && <5
+ -- The applicable version of the Haskell language:
+ default-language: Haskell2010
+
+ -- The executable 'helloworld-exe' component of the package. Executable
+ -- components have fields in common with library components:
+ executable helloworld-exe
+ -- The source file exporting the 'main' function:
+ main-is: Main.hs
+ other-modules:
+ Paths_helloworld
+ autogen-modules:
+ Paths_helloworld
+ hs-source-dirs:
+ app
+ -- GHC options applicable to the component. In this case, they include
+ -- flags that affect GHC's runtime system (RTS).
+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates
+ -Wincomplete-uni-patterns -Wmissing-export-lists
+ -Wmissing-home-modules -Wpartial-fields
+ -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
+ build-depends:
+ base >=4.7 && <5
+ , helloworld
+ default-language: Haskell2010
+
+ -- The test suite 'helloworld-test' component of the package. Test suite
+ -- components have fields in common with executable components:
+ test-suite helloworld-test
+ -- The type of the test suite:
+ type: exitcode-stdio-1.0
+ main-is: Spec.hs
+ other-modules:
+ Paths_helloworld
+ autogen-modules:
+ Paths_helloworld
+ hs-source-dirs:
+ test
+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates
+ -Wincomplete-uni-patterns -Wmissing-export-lists
+ -Wmissing-home-modules -Wpartial-fields
+ -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
+ build-depends:
+ base >=4.7 && <5
+ , helloworld
+ default-language: Haskell2010
+ ~~~
+
+## `Setup.hs`
+
+The `Setup.hs` file is a component of the Cabal build system.
+
+Technically, it is not needed by Stack, but it is considered good practice to
+include it. The file we're using is boilerplate:
+
+~~~haskell
+import Distribution.Simple
+main = defaultMain
+~~~
diff --git a/doc/tutorial/project_configuration.md b/doc/tutorial/project_configuration.md
new file mode 100644
index 0000000000..12c4d51846
--- /dev/null
+++ b/doc/tutorial/project_configuration.md
@@ -0,0 +1,55 @@
+
+
+# 3. Project configuration
+
+Let us continue to look at the `helloworld` example in more detail to understand
+better how Stack works.
+
+As discussed in the previous part of this guide to getting started, some of the
+contents of the project directory are set out below. The item of interest here
+is the `stack.yaml` file.
+
+~~~text
+.
+├── .stack-work
+│ └── ...
+...
+│
+├── package.yaml
+├── helloworld.cabal
+├── Setup.hs
+│
+└── stack.yaml
+~~~
+
+## `stack.yaml`
+
+Stack requires a Stack project-level configuration file for every project.
+`stack.yaml` is that file. The contents of the file define project-specific
+options and non-project-specific options that apply to the project.
+
+The contents of the file include comments beginning `#`. Ignoring those
+comments, the contents will look something like this:
+
+~~~yaml
+snapshot:
+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/31.yaml
+packages:
+- .
+~~~
+
+The key [`snapshot`](../configure/yaml/project.md#snapshot) is a
+project-specific configuration option. Its value tells Stack *how* to build your
+package: which GHC version to use, which versions of package dependencies to
+use, and so on. Our value here says to use
+[LTS Haskell 22.31](https://www.stackage.org/lts-22.31), which implies GHC 9.6.6
+(which is why `stack build` installs that version of GHC if it is not already
+available to Stack). There are a number of values you can use for `snapshot`,
+which we'll cover later.
+
+The key [`packages`](../configure/yaml/project.md#packages) is another
+project-specific configuration option. Its value tells Stack which project
+packages, located locally, to build. In our simple example, we have only a
+single project package, located in the same directory, so '`.`' suffices.
+However, Stack has powerful support for multi-package projects, which we'll
+describe as this guide progresses.
diff --git a/doc/tutorial/stack_build_synonyms.md b/doc/tutorial/stack_build_synonyms.md
index 271e071367..3a845ade71 100644
--- a/doc/tutorial/stack_build_synonyms.md
+++ b/doc/tutorial/stack_build_synonyms.md
@@ -1,6 +1,6 @@
-# 5. `stack build` synonyms
+# 7. `stack build` synonyms
Let's look at a subset of the `stack --help` output:
diff --git a/doc/tutorial/stack_build_targets.md b/doc/tutorial/stack_build_targets.md
index 1f31a2e1d8..66c1b72337 100644
--- a/doc/tutorial/stack_build_targets.md
+++ b/doc/tutorial/stack_build_targets.md
@@ -1,6 +1,6 @@
-# 6. `stack build` targets
+# 8. `stack build` targets
We haven't discussed this too much yet, but, in addition to having a number of
synonyms *and* taking a number of options on the command line, the `build`
diff --git a/doc/tutorial/stack_configuration.md b/doc/tutorial/stack_configuration.md
index 909bb0759f..367f045715 100644
--- a/doc/tutorial/stack_configuration.md
+++ b/doc/tutorial/stack_configuration.md
@@ -1,6 +1,6 @@
-# 12. Stack configuration
+# 14. Stack configuration
Whenever you run something with Stack, it needs a project-level configuration
file. The algorithm Stack uses to find such a file is:
diff --git a/doc/tutorial/tutorial_conclusion.md b/doc/tutorial/tutorial_conclusion.md
index 480829967f..3c9b8feee3 100644
--- a/doc/tutorial/tutorial_conclusion.md
+++ b/doc/tutorial/tutorial_conclusion.md
@@ -1,6 +1,6 @@
-# 13. In conclusion
+# 15. In conclusion
Stack is not the only tool available for building Haskell code. If you are
happy building Haskell code with other tools, you may not need Stack. If
diff --git a/doc/tutorial/using_ghc_interactively.md b/doc/tutorial/using_ghc_interactively.md
index 3bb323dc20..5a8c7eb175 100644
--- a/doc/tutorial/using_ghc_interactively.md
+++ b/doc/tutorial/using_ghc_interactively.md
@@ -1,6 +1,6 @@
-# 11. Using GHC interactively
+# 13. Using GHC interactively
GHCi is the interactive GHC environment, a.k.a. the REPL. You *could* access it
with command:
diff --git a/mkdocs.yml b/mkdocs.yml
index 28355fc683..e8d2a86058 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -35,18 +35,20 @@ nav:
- Getting started:
- tutorial/index.md
- 1. A Hello World example: tutorial/hello_world_example.md
- - 2. Building your project: tutorial/building_your_project.md
- - 3. Building existing projects: tutorial/building_existing_projects.md
- - 4. Installed package databases: tutorial/installed_package_databases.md
- - 5. stack build synonyms: tutorial/stack_build_synonyms.md
- - 6. stack build targets: tutorial/stack_build_targets.md
- - 7. Multi-package projects: tutorial/multi-package_projects.md
- - 8. Cabal flags and GHC options: tutorial/cabal_flags_and_ghc_options.md
- - 9. Locations used by Stack: tutorial/locations_used_by_stack.md
- - 10. Executing commands: tutorial/executing_commands.md
- - 11. Using GHC interactively: tutorial/using_ghc_interactively.md
- - 12. Stack configuration: tutorial/stack_configuration.md
- - 13. In conclusion: tutorial/tutorial_conclusion.md
+ - 2. Package description: tutorial/package_description.md
+ - 3. Project configuration: tutorial/project_configuration.md
+ - 4. Building your project: tutorial/building_your_project.md
+ - 5. Building existing projects: tutorial/building_existing_projects.md
+ - 6. Installed package databases: tutorial/installed_package_databases.md
+ - 7. stack build synonyms: tutorial/stack_build_synonyms.md
+ - 8. stack build targets: tutorial/stack_build_targets.md
+ - 9. Multi-package projects: tutorial/multi-package_projects.md
+ - 10. Cabal flags and GHC options: tutorial/cabal_flags_and_ghc_options.md
+ - 11. Locations used by Stack: tutorial/locations_used_by_stack.md
+ - 12. Executing commands: tutorial/executing_commands.md
+ - 13. Using GHC interactively: tutorial/using_ghc_interactively.md
+ - 14. Stack configuration: tutorial/stack_configuration.md
+ - 15. In conclusion: tutorial/tutorial_conclusion.md
- Commands:
- commands/index.md
- bench: commands/bench_command.md
diff --git a/stack.cabal b/stack.cabal
index 7dede6556e..21b08e210d 100644
--- a/stack.cabal
+++ b/stack.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.0
--- This file has been generated from package.yaml by hpack version 0.36.0.
+-- This file has been generated from package.yaml by hpack version 0.37.0.
--
-- see: https://github.com/sol/hpack
@@ -129,6 +129,8 @@ extra-source-files:
doc/tutorial/installed_package_databases.md
doc/tutorial/locations_used_by_stack.md
doc/tutorial/multi-package_projects.md
+ doc/tutorial/package_description.md
+ doc/tutorial/project_configuration.md
doc/tutorial/stack_build_synonyms.md
doc/tutorial/stack_build_targets.md
doc/tutorial/stack_configuration.md