Skip to content

Commit 24e8d6d

Browse files
authored
Added review suggestions
1 parent 00b3b4f commit 24e8d6d

File tree

1 file changed

+18
-36
lines changed

1 file changed

+18
-36
lines changed

doc/getting-started.rst

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To initialize a new Haskell application, run
3030
3131
$ cabal init myapp --non-interactive
3232
33-
in a terminal. This generates the following files in a new ``myapp`` folder:
33+
in a terminal. This generates the following files in a new ``myapp`` directory:
3434

3535
.. code-block:: console
3636
@@ -42,8 +42,7 @@ in a terminal. This generates the following files in a new ``myapp`` folder:
4242
├── CHANGELOG.md
4343
└── myapp.cabal
4444
45-
``myapp.cabal`` is a package description file (commonly referred to as a "Cabal file"), which contains basic metadata (package name and version, author name, etc.),
46-
its dependencies and how it is built:
45+
``myapp.cabal`` is a "package description file", commonly referred to as a "Cabal file":
4746

4847
.. code-block:: cabal
4948
@@ -59,9 +58,13 @@ its dependencies and how it is built:
5958
hs-source-dirs: app
6059
default-language: Haskell2010
6160
62-
The ``executable`` section shows that this package has a component named ``myapp``
63-
of the executable type .
64-
The ``build-depends`` section contains a list of the component's dependencies.
61+
It contains metadata (package name and version, author name, license, etc.) and sections
62+
to define package components. Components can be used to split large codebases into smaller,
63+
more managable building blocks.
64+
A component can be of one of several types (executable, library, etc.) and describes,
65+
among other things, the location of source files and its dependencies.
66+
The ``myapp.cabal`` file above defines a single component named ``myapp`` of the executable type.
67+
Inside that ``executable`` section ``build-depends`` lists the dependencies of this component.
6568

6669

6770
``app/Main.hs`` is where your executable's code lives:
@@ -78,12 +81,13 @@ To run the executable, switch into the project directory with ``cd myapp`` and
7881

7982
.. code-block:: console
8083
81-
$ cabal run
84+
$ cabal run myapp
8285
...
8386
Hello, Haskell!
8487
85-
The command ``cabal run`` automatically determines if the executable needs to be (re)built
86-
before running the executable.
88+
This command automatically determines if the executable needs to be (re)built
89+
before running the executable. With only one executable component in the package,
90+
``cabal run`` (without a component name) is smart enough to infer it, so the name can be omitted.
8791

8892
If you just want to build the executable without running it, run:
8993

@@ -152,7 +156,7 @@ Now you can build and re-run your code to see the new output:
152156

153157
.. code-block:: console
154158
155-
$ cabal run
159+
$ cabal run myapp
156160
________________________________________________________
157161
/ \
158162
| Hello, Haskell! |
@@ -203,7 +207,8 @@ Use the familiar ``cabal run`` command to execute this script:
203207
204208
$ cabal run myscript
205209
206-
On Unix-like systems, a script can be run directly with the execute permission.
210+
On Unix-like systems, a Haskell script starting with ``#!/usr/bin/env cabal`` like the above can be run directly
211+
after setting the execute permission (+x):
207212

208213
.. code-block:: console
209214
@@ -212,31 +217,8 @@ On Unix-like systems, a script can be run directly with the execute permission.
212217
________________________________________________________
213218
/ \
214219
| Hello, Haskell! |
215-
\____ _____________________________________________/
216-
\ /
217-
\ /
218-
\/
219-
_____ _____
220-
\ \ \ \
221-
\ \ \ \
222-
\ \ \ \
223-
\ \ \ \ \-----------|
224-
\ \ \ \ \ |
225-
\ \ \ \ \---------|
226-
/ / / \
227-
/ / / \ \-------|
228-
/ / / ^ \ \ |
229-
/ / / / \ \ \ ----|
230-
/ / / / \ \
231-
/____/ /____/ \____\
232-
233-
Project metadata can also be included:
234-
235-
.. code-block:: haskell
236-
237-
{- project:
238-
with-compiler: ghc-9.4.7
239-
-}
220+
\____ ____________________________________________/
221+
\ ... /
240222
241223
See more in the documentation for :ref:`cabal run`.
242224

0 commit comments

Comments
 (0)