-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minimal example to README #533
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Roosembert Palacios <[email protected]>
@sol Gentle ping ^^ |
The following `package.yaml` describes a project with a library under `src`, an executable under `app/Main.hs` and tests under `test/Main.hs`: | ||
|
||
```yaml | ||
name: mylib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps my-package
would be a better dummy name, as this will produce a Cabal file for a package with more than a library component.
@@ -32,6 +32,35 @@ at the Singapore Haskell meetup: http://typeful.net/talks/hpack | |||
|
|||
## Examples | |||
|
|||
The following `package.yaml` describes a project with a library under `src`, an executable under `app/Main.hs` and tests under `test/Main.hs`: | |||
|
|||
```yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would include spec-version: 0.36.0
, to ensure modern behaviour.
name: mylib | ||
|
||
dependencies: | ||
- base >= 4.9 && < 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the basis for these bounds? The generated Cabal file will specify cabal-version: 1.12
which might imply base >= 4.4
(GHC 7.2.1 came with Cabal-1.12.0
).
library: | ||
source-dirs: src | ||
|
||
executable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While executable: { ... }
is strictly minimal, perhaps executables: { my-exe: { ... } }
would be more useful?
- mylib | ||
|
||
tests: | ||
spec: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps my-test-suite
or my-package-test
(given what cabal init
would suggest) would be a better dummy name than spec
?
main: Main.hs | ||
source-dirs: | ||
- test | ||
- src |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a minimal example, why include src
as a source directory for the source code of a test suite application (also given what cabal init
would suggest)?
- test | ||
- src | ||
dependencies: | ||
- QuickCheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a minimal example, I would expect a dependency on the package itself but not QuickCheck
.
@@ -32,6 +32,35 @@ at the Singapore Haskell meetup: http://typeful.net/talks/hpack | |||
|
|||
## Examples | |||
|
|||
The following `package.yaml` describes a project with a library under `src`, an executable under `app/Main.hs` and tests under `test/Main.hs`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, strictly, (if you follow my other suggestions below):
... a package with a main library with source code under directory `src`, an
executable named `my-exe` with source code under `app`, and a test suite named
`my-test-suite` with source code under `test`:
@@ -32,6 +32,35 @@ at the Singapore Haskell meetup: http://typeful.net/talks/hpack | |||
|
|||
## Examples | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth acknowledging in the introduction that users of Stack have access to templates for projects that include package.yaml
files, but users of Cabal (the tool) may find the minimal example useful.
Motivation for this MR
Every time I start working in a new Haskell project, I find myself in this
repository's README, copy one of the provided examples, but spend most of the
time removing keys I don't need. I think a simple example one can simply
'copy over' is both useful to making the tool accessible to beginners and
a practical base for experienced developers to build on.
Changes in this MR
This MR adds a short and simple example, matching the default
cabal init
'Library and Executable' generation (
app
andtest
directories withMain.hs
inside them and library insidesrc
).