Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions src/preamble/01_what_do_we_mean_when_we_say_cabal.md
Original file line number Diff line number Diff line change
@@ -1 +1,96 @@
# What do we mean when we say cabal?

Cabal is an umbrella term that can refer to either "cabal the spec" (.cabal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the package spec"? I wasn't sure if you mean "specification of the cabal software system" or "cabal format spec" or "cabal protocol spec".

files), "cabal the library" (code that understands .cabal files), or "cabal the
tool" (the cabal-install package which provides the cabal executable).

## tl;dr

1. [.cabal file](#the-cabal-file) This is the file that specifies the content of
Haskell packages. The types of information that can be provided via the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd cross out "that can be". There is not so much optionality here, no defaults, a lot of the info is mandatory.

bespoke file format are: top level metadata about the package, and build
specific information (exposed modules, external dependencies, language
extensions, compiler options) about the components that comprise the package.

2. [The Cabal build system](#the-cabal-library) is a library that is used for
creating packages and building their contents. This build system is used by
cabal-install and other package managers, stack for example.

3. [cabal-install](#the-binary-cabal-install-cli-tool) is the command line
utility to help configure, compile and install Haskell libraries and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change "to help configure" to "for configuring", or something similar, because cabal-install is not a helper that makes it easier. There are no ways to do that except via cabal-inistall.

programs.

## The .cabal file

The .cabal file contains information that drives the compilation and building of
Haskell packages. The .cabal file lives at the root directory that contains the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a native speaker, but I suspect "in root directory".

haskell source code corresponding to the package. By convention this file is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rephrase to "in root directory of the source tree of the package". Root directory does not contain code. It contains other directories that contain code and other directories, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a native speaker, so I'm not sure about 'convention'. This is mandatory, so surely not a social convention, but built into the format. Not sure how to better express that.

named `<project-name>.cabal`. It is a text-based, key-value format, that is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"It is in a ,.. format". We are still talking about the file, not its format. So file is in format. Format is text-based.

divided into subsections called stanzas.

The package properties describe the package as a whole, such as name, license,
author, dependenices, etc. It also contains information about optional
components such as [library](../new_to_cabal/06_first_cabal_library.md),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either 'libraries' or reword, because a single library is mandatory, everything else is optional.

[executables](../new_to_cabal/07_first_cabal_executable.md),
[test-suite](../leveling_up/02_first_cabal_test-suite.md),
[benchmark](src/leveling_up/03_first_cabal_benchmark.md). These components are
Comment on lines +35 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test-suites, benchmarks; they can be many, as well.

also called stanzas.

One of the purposes of Cabal is to make it easier to build a package with
different Haskell implementations. So it provides abstractions of features
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that currently GHC is virtually the only one, I'd clarify "(e.g., different versions of the GHC compiler or one of the past or future competitors)". Because there is no present competitor, sadly. :)

present in different Haskell implementations and wherever possible it is best to
take advantage of these to increase portability. For example one of the pieces
Comment on lines +41 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be a little less proscriptive and condense to "present in different Haskell implementations that can be used to increase portability.".

of information an author can put in the package’s .cabal file is what language
extensions the code uses. This is preferable to specifying flags for a specific
compiler as it allows Cabal to pick the right flags for the Haskell
implementation that the user picks. It also allows Cabal to figure out if the
language extension is even supported by the Haskell implementation that the user
picks. Where compiler-specific options are needed, there is an “escape hatch”
available. The developer can specify implementation-specific options and more
generally there is a configuration mechanism to customise many aspects of how a
package is built depending on the Haskell implementation, the operating system,
computer architecture and user-specified configuration flags.

There are various
[Haskell implementations](https://wiki.haskell.org/Implementations), but we have
now pretty much all converged on [GHC](https://www.haskell.org/ghc/) as the
standard Haskell implementation.

Comment on lines +54 to +58
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we mention GHC above, as suggested, I'd remove this. Perhaps re-use the links, GHC for GHC, Implementations for "past and future competitors".

## The CABAL library

Cabal stands for Common Architecture for Building Applications and Libraries.
This is the library that provides functionality that allows the information in
the .cabal files to be put to use. The Cabal library contains the code for
Comment on lines +62 to +63
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet you could condense this sentence to half the length. :)

parsing .cabal files and operations for building haskell packages. Cabal the
library, by convention, is written with Capitalization case. Cabal can take a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a native speaker, so I'd need to google to understand what "Capitalization case" means.

haskell dependency graph (of external and internal modules) and use GHC to build
it.
Comment on lines +65 to +67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say "Cabal generates a dependency graph (of external and internal packages and modules) and repeatedly calls GHC to build it."


## The binary cabal-install (cli tool)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hard, because the exe is not called cabal-install and we don't want to mislead the users. How about "The commandline tool (cabal-instal)"? I'm not happy with that either.


The cabal binary or more accurately `cabal-install` is the command-line tool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd repeat the section title: "The commandline tool project called cabal-install, with the executable confusingly named cabal, provides user interface..."

that provides a user interface for dealing with Haskell packages. cabal-install
makes use of Cabal the library to do its job.

cabal-install is a frontend to Cabal. It makes it possible to build Haskell
Comment on lines +72 to +75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two sentences are almost repeated.

projects whose sets of dependencies might conflict with each other within the
confines of a single system. A package's .cabal file provides a constraint on
Comment on lines +75 to +77
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important point, but hard to get across. Perhaps " It's perfectly comfortable building two Haskell projects whose sets of dependencies are conflicting and storing their artefacts to be concurrently employed by the user."

the version of various libraries (version bounds) that they expect. When
cabal-install is asked to build a project, by default it looks at the
dependencies specified in its .cabal file and uses a dependency solver to figure
out a set of packages and package versions that satisfy it. This set of packages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say "packages with their versions" to be able to later on omit "and package versions".

is drawn from Hackage. The chosen versions of the dependenices will be installed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Hackage (the central Haskell package repository) or another repository specified by the user"; BTW, typo: dependenices

and indexed in a database in the cabal directory (`~/.cabal`).

Conflicts between dependencies are avoided by indexing the installed packages
according to their version and other relevant configuration options. This allows
different projects to retrieve the dependency versions they need.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add "dependency versions and build flavours".


stack is also a command-line tool that depends on the Cabal Library, and hence
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be high-minded and also compliment ourselves saying something like "stack is another mature command-line tool, with somewhat different goals and trade-offs, that depends...".

also consumes the information specified in Cabal Package format found in the
.cabal files.

# References

1. [Cabal hackage page](https://hackage.haskell.org/package/Cabal)
2. [cabal-install hackage page](https://hackage.haskell.org/package/cabal-install)