You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/getting-started.rst
+18-36Lines changed: 18 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ To initialize a new Haskell application, run
30
30
31
31
$ cabal init myapp --non-interactive
32
32
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:
34
34
35
35
.. code-block:: console
36
36
@@ -42,8 +42,7 @@ in a terminal. This generates the following files in a new ``myapp`` folder:
42
42
├── CHANGELOG.md
43
43
└── myapp.cabal
44
44
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":
47
46
48
47
.. code-block:: cabal
49
48
@@ -59,9 +58,13 @@ its dependencies and how it is built:
59
58
hs-source-dirs: app
60
59
default-language: Haskell2010
61
60
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.
65
68
66
69
67
70
``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
78
81
79
82
.. code-block:: console
80
83
81
-
$ cabal run
84
+
$ cabal run myapp
82
85
...
83
86
Hello, Haskell!
84
87
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.
87
91
88
92
If you just want to build the executable without running it, run:
89
93
@@ -152,7 +156,7 @@ Now you can build and re-run your code to see the new output:
0 commit comments