Exercism Haskell Track
Exercism exercises in Haskell
- Asking for help
- How to contribute
- Repository structure and conventions
- Writing an issue
- Writing a pull request
- Development Dependencies
- Stub solution
- Example solution
- Test suite
- Running tests
- Running HLint
Asking for help
When in doubt just ask!
In any case, don't be afraid or shy! We promise to be friendly and as helpful as possible.
How to contribute
As a first step we recommend you read the contributing documentation.
Reporting or fixing bugs
Typical examples for a bug: A typo, a missing test case, an unclear or ambiguous problem description.
- If you are unsure whether you have really found a bug just ask.
- To report a bug you can write an issue.
- If you already have a fix for it you may write a pull request.
Reviewing issues and pull requests
The site contains a list of missing exercises. You may implement any of these exercises for the Haskell track. Feel free to refer to the documentation on porting an exercise. Of course you can also add a totally new exercise, but it might be a good idea to first discuss it in one of our forums.
Updating an exercise test suite
Updating a test suite of an existing exercise is special because it usually affects all languages. You can refer to the documentation on updating a test suite and the test suite principles. Note that the whole test suite must run with the sample solution within a couple of seconds.
Repository structure and conventions
The track anatomy documentation is a general description of all the files and directories that are not explicitly described below.
├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── bin │ └── fetch‐configlet ├── config.json ├── docs │ ├── ABOUT.md ├── EXERCISE_README_INSERT.md │ ├── INSTALLATION.md │ ├── LEARNING.md │ ├── RESOURCES.md │ └── TESTS.md └── exercises └── accumulate │ ├── package.yaml │ ├── stack.yaml │ ├── examples │ │ └── success-standard │ │ ├── package.yaml │ │ └── src │ │ └── Accumuĺate.hs │ ├── src │ │ └── Accumuĺate.hs │ ├── test │ │ └── Tests.hs │ └── .meta │ └── hints.md └── allergies │ ├── ... └── ...
config.json: Every exercise has to be registered here. It has a unique name and a difficulty. The sequence order is also the default order in which the exercises are fetched.
Each exercise has the following structure:
stack.yamlhas just one line specifying the current Stack snapshot. We use the same resolver for all the exercises.
package.yamlis a file in the hpack format that has all dependencies and build instructions for an exercise. One of the properties tracked in
package.yamlis the version of the exercise.
src/ModuleName.hsis a stub solution.
examples/success-<name>/package.yamlcontains library dependencies for the example solution.
<name>is a unique name for the example - usually "standard" (as in
success-standard), but it can be some other name in case of multiple example solutions.
examples/success-<name>/src/ModuleName.hsis the source code of the sample solution.
test/Tests.hsis the test suite.
.meta/hints.mdis an optional file containing instructions and/or hints. It is used together with the respective
description.mdfor the exercise from problem-specifications to build the
Each exercise contains a four-part version in its
package.yaml file, MAJOR.MINOR.PATCH.SERIAL.
There are two possibilities for the meaning of the MAJOR.MINOR.PATCH components:
- Exercises based on a
canonical-data.jsonin problem-specifications should use its version plus a serial number.
- Exercises that are not based on
canonical-data.jsonshould use version 0.1.0 plus a serial number.
The serial number starts at 1 and always increases when the tests are changed, regardless of the changes in other version numbers.
When changing a test suite, the version number should be updated appropriately so that:
- It is possible for maintainers of this track to tell whether test suites are up to date with https://github.com/exercism/problem-specifications.
- It is easier for students to determine at-a-glance whether they have the same tests, by comparing version numbers.
This versioning policy was proposed and accepted in https://github.com/exercism/haskell/issues/522.
Writing an issue
Writing a pull request
You should have Stack installed in your system to make contributing to this repository easier.
The stub solution should be as general as possible in order to not exclude any possible solutions. It should take Haskell specifics into account (for example use
Maybe instead of a dummy return value). It should not contain any comments (people might forget to remove them), you can use the hints file instead.
The stub solution must compile by itself (with
Ideally, it would also compile together with the test suite (with
stack test --no-run-tests).
These two conditions are enforced by Travis.
If the second condition cannot be met for a good reason, place the explanation in
.meta/DONT-TEST-STUB to circumvent the check.
The first condition is always enforced and cannot be circumvented.
The example solution could be inspiration for other language implementors. It doesn't need to be perfect or very elegant. But it should be efficient enough for the test suite to finish in only a few seconds.
Examples are named
There are three possible types of examples:
- success: The example is expected to pass the tests. There should be at least one of these per exercise.
- fail: The example is expected to build, but fail the tests.
- error: The example is expected to fail to build.
The test suite should be derived from the respective
problem-specifications/exercises/<exercise-name>/canonical-data.json and comply to some formatting and coding standards (to get an idea you may look at some of the existing tests).
In order to be accepted by Travis-CI, every exercise must be registered in
config.json, it must compile without warnings and the example solution must
pass the tests without failures. Additionally the tests should not run longer than
a few seconds.
First you need to provide an example solution.
We provide three scripts in the
bin directory of this repository to run the tests.
These are the same scripts as those used by Travis CI.
test-example path/to/example/dirruns the tests on a single example.
test-all-examples path/to/exercise/dirruns the tests on all examples for an exercise.
test-stub path/to/exercise/dirchecks that the stub for the given exercise compiles.
All code in this repository should be as idiomatic as possible, so we
enforce in Travis-CI that it returns
No hints when processed by
It is highly recommended to run
hlint on your sources before opening
a pull request, so you can fix your code before submitting it for review.
If you are certain that a suggestion given by
hlint would make the
code worse, you can suppress it
with annotations in the source file.
The Haskell icon was designed by Darrin Thompson and Jeff Wheeler. It was released under the HaskellWiki license.