Skip to content

Commit

Permalink
Added review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
malteneuss authored Oct 13, 2023
1 parent 00b3b4f commit 24e8d6d
Showing 1 changed file with 18 additions and 36 deletions.
54 changes: 18 additions & 36 deletions doc/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To initialize a new Haskell application, run
$ cabal init myapp --non-interactive
in a terminal. This generates the following files in a new ``myapp`` folder:
in a terminal. This generates the following files in a new ``myapp`` directory:

.. code-block:: console
Expand All @@ -42,8 +42,7 @@ in a terminal. This generates the following files in a new ``myapp`` folder:
├── CHANGELOG.md
└── myapp.cabal
``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.),
its dependencies and how it is built:
``myapp.cabal`` is a "package description file", commonly referred to as a "Cabal file":

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


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

.. code-block:: console
$ cabal run
$ cabal run myapp
...
Hello, Haskell!
The command ``cabal run`` automatically determines if the executable needs to be (re)built
before running the executable.
This command automatically determines if the executable needs to be (re)built
before running the executable. With only one executable component in the package,
``cabal run`` (without a component name) is smart enough to infer it, so the name can be omitted.

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

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

.. code-block:: console
$ cabal run
$ cabal run myapp
________________________________________________________
/ \
| Hello, Haskell! |
Expand Down Expand Up @@ -203,7 +207,8 @@ Use the familiar ``cabal run`` command to execute this script:
$ cabal run myscript
On Unix-like systems, a script can be run directly with the execute permission.
On Unix-like systems, a Haskell script starting with ``#!/usr/bin/env cabal`` like the above can be run directly
after setting the execute permission (+x):

.. code-block:: console
Expand All @@ -212,31 +217,8 @@ On Unix-like systems, a script can be run directly with the execute permission.
________________________________________________________
/ \
| Hello, Haskell! |
\____ _____________________________________________/
\ /
\ /
\/
_____ _____
\ \ \ \
\ \ \ \
\ \ \ \
\ \ \ \ \-----------|
\ \ \ \ \ |
\ \ \ \ \---------|
/ / / \
/ / / \ \-------|
/ / / ^ \ \ |
/ / / / \ \ \ ----|
/ / / / \ \
/____/ /____/ \____\
Project metadata can also be included:

.. code-block:: haskell
{- project:
with-compiler: ghc-9.4.7
-}
\____ ____________________________________________/
\ ... /
See more in the documentation for :ref:`cabal run`.

Expand Down

0 comments on commit 24e8d6d

Please sign in to comment.