• Stars
    star
    450
  • Rank 97,143 (Top 2 %)
  • Language
    Haskell
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Exercism exercises in Haskell.

Exercism Haskell Track

Tests

Exercism exercises in Haskell

How to contribute

Git and GitHub

If you would like to contribute but lack experience with git and/or GitHub, try these resources:

Report or fix a bug

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 create an issue.
  • If you already have a fix for it, you may submit a pull request.

Review issues and pull requests

If you have a dedicated opinion you are welcome to write a comment for an issue or a pull request.

Please be detailed and include reasons, links or arguments to support your opinion.

Port or create an exercise

Exercism contains two types of exercises: concept exercises, and practice exercises.

Haskell has some concept exercises. You can read about concept exercises and take part in creating Haskell's learning track.

You can get a full list of common Exercism practice exercises and cross-reference it with Haskell practice exercises and implement any of the missing ones for the Haskell track.

Port or create a concept

Concepts are short tutorials explaining a single feature of the language. The Haskell track has a few concepts currently developed and a list of additional concepts yet to be created. You can contribute by porting (from the F# or Elm tracks for example) or developing any of the topics listed in reference/concepts.md

Port or create a concept exercise

Each concept is accompanied by a concept exercise to test the student understood the basic use of the concept and unlock the next concept(s). To develop concept exercises see reference/implementing-a-concept-exercise.md

Update an exercise test suite

Most unit tests are shared between language tracks. You may update a test suite with new unit tests.

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.

Directory structure

├── .gitignore
├── .github
│   └── workflows
│       └── tests.yml
├── LICENSE
├── README.md
├── bin
│   └── fetch‐configlet
├── concepts
│   ├── basics
│   │   ├── about.md
│   │   ├── introduction.md
│   │   └── links.json
│   └── ...
├── config.json
├── docs
│   ├── ABOUT.md
│   ├── EXERCISE_README_INSERT.md
│   ├── INSTALLATION.md
│   ├── LEARNING.md
│   ├── RESOURCES.md
│   └── TESTS.md
└── exercises
    ├── concept
    │   ├── AnnalynsInfiltration
    │   │   ├── package.yaml
    │   │   ├── stack.yaml
    │   │   ├── src
    │   │   │   └── AnnalynsInfiltration.hs
    │   │   ├── test
    │   │   │   └── Tests.hs
    │   │   ├── .docs
    │   │   │   ├── instructions.md
    │   │   │   ├── introduction.md
    │   │   │   └── hints.md
    │   │   └── .meta
    │   │       ├── config.json
    │   │       ├── design.md
    │   │       └── exemplar
    │   │           ├── package.yaml
    │   │           └── src
    │   │               └── AnnalynsInfiltration.hs
    │   └── ...
    └── practice
        ├── accumulate
        │   ├── package.yaml
        │   ├── stack.yaml
        │   ├── src
        │   │   └── Accumulate.hs
        │   ├── test
        │   │   └── Tests.hs
        │   ├── .docs
        │   │   └── instructions.md
        │   └── .meta
        │       ├── examples
        │       │   └── success-standard
        │       │       ├── package.yaml
        │       │       └── src
        │       │           └── Accumulate.hs
        │       ├── config.json
        │       └── 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.

Practice exercise structure

Each practice exercise has the following structure:

  • stack.yaml has just one line specifying the current Stack snapshot. We use the same resolver for all the exercises.
  • package.yaml is a file in the hpack format that has all dependencies and build instructions for an exercise. One of the properties tracked in package.yaml is the version of the exercise.
  • src/ModuleName.hs is a stub solution.
  • .docs/instructions.md contains the instructions and requirements to complete the exercise. For an exercise from problem-specifications, this file should exactly match the description.md from problem-specifications. The Exercism-wide documentation for instructions.md contains more information.
  • .meta/examples/success-<name>/package.yaml contains 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.
  • .meta/examples/success-<name>/src/ModuleName.hs is the source code of the sample solution.
  • test/Tests.hs is the test suite.
  • .meta/hints.md is an optional file containing instructions and/or hints. It is used together with the respective description.md for the exercise from problem-specifications to build the README.md file.
  • .meta/config.json is the exercise configuration file. The Exercism-wide documentation for .meta/config.json contains more information.

Exercise versioning

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.json in problem-specifications should use its version plus a serial number.
  • Exercises that are not based on canonical-data.json should 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 #522.

Development Dependencies

You should have Stack installed in your system to make contributing to this repository easier.

Stub solution

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 stack build). Ideally, it would also compile together with the test suite (with stack test --no-run-tests). These two conditions are enforced by GitHub Actions CI. 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.

Example solution

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 <type>-<name>. There are three possible types of examples:

  • success: The example is expected to pass the tests.
    • There must be at least success example per exercise, in order to confirm that it is possible to solve the tests.
    • There may be more than one success example for a given exercise, but these are intended for use when we want to confirm that multiple type signatures for a given solution will compile and pass the tests.
    • We do not intend to use multiple success examples just to showcase a wide variety of possible solutions, since that is not in the goals of this repository.
  • fail: The example is expected to build, but fail the tests.
    • These are intended for use when we want to make sure that the track tests have coverage: Whether the tests find certain classes of incorrect or inefficient solutions.
    • It's suggested that these only be used for tests that are specific to the track. This is under the assumption that tests sourced from problem-specifications have already been judged to have appropriate coverage by the reviewers of the problem-specifications repository.
  • error: The example is expected to fail to build.
    • There is only one intended use of this so far, and that is a single check that a solution without a type signature will fail to build (because CI builds with --pedantic).
    • We do not intend for any additional uses of this type of example.

These example types were proposed and accepted in #397.

Test suite

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).

Running Tests

In order to be accepted by GitHub Actions, 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 GitHub Actions.

  • test-example path/to/example/dir runs the tests on a single example.
  • test-all-examples path/to/exercise/dir runs the tests on all examples for an exercise.
  • test-stub path/to/exercise/dir checks that the stub for the given exercise compiles.

Running HLint

All code in this repository should be as idiomatic as possible, so we enforce in GitHub Actions that it returns No hints when processed by HLint.

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.

Automated Test Runner

We have a test runner to automatically run tests on Haskell solutions submitted to exercism.

More Repositories

1

exercism

Crowd-sourced code mentorship. Practice having thoughtful conversations about code.
7,312
star
2

python

Exercism exercises in Python.
Python
1,863
star
3

cli

A Go based command line tool for exercism.org.
Go
1,267
star
4

rust

Exercism exercises in Rust.
Rust
1,191
star
5

go

Exercism exercises in Go.
Go
986
star
6

java

Exercism exercises in Java.
Java
686
star
7

elixir

Exercism exercises in Elixir.
Elixir
570
star
8

javascript

Exercism exercises in JavaScript.
JavaScript
560
star
9

ruby

Exercism exercises in Ruby.
Ruby
498
star
10

website

The codebase for Exercism's website.
Ruby
405
star
11

problem-specifications

Shared metadata for exercism exercises.
Ruby
310
star
12

csharp

Exercism exercises in C#.
C#
276
star
13

c

Exercism exercises in C.
C
249
star
14

cpp

Exercism exercises in C++.
C++
226
star
15

website-copy

A repository for exercism's website's copy
HTML
198
star
16

DEPRECATED.javascript

Exercism exercises in JavaScript.
JavaScript
194
star
17

kotlin

Exercism exercises in Kotlin.
Kotlin
192
star
18

windows-installer

A project to download and install the latest version of Exercism Client for Windows depending on the architecture.
Pascal
190
star
19

v3

The work-in-progress project for developing v3 tracks
C#
170
star
20

typescript

Exercism exercises in TypeScript.
JavaScript
145
star
21

clojure

Exercism exercises in Clojure.
Clojure
144
star
22

php

Exercism exercises in PHP.
PHP
129
star
23

elm

Exercism exercises in Elm.
Elm
129
star
24

v2-website

Exercism — Code practice and mentorship for everyone.
Ruby
125
star
25

erlang

Exercism exercises in Erlang.
Erlang
124
star
26

scala

Exercism exercises in Scala.
Scala
115
star
27

fsharp

Exercism exercises in F#.
F#
106
star
28

swift

Exercism exercises in Swift.
Swift
101
star
29

bash

Exercism exercises in Bash.
Shell
92
star
30

ocaml

Exercism exercises in OCaml.
OCaml
91
star
31

legacy-docs

84
star
32

gleam

Exercism exercises in Gleam.
Gleam
81
star
33

common-lisp

Exercism exercises in Common Lisp.
Common Lisp
76
star
34

crystal

Exercism exercises in Crystal.
Crystal
70
star
35

abap

Exercism exercises in ABAP.
ABAP
63
star
36

julia

Exercism exercises in Julia.
Julia
61
star
37

nim

Exercism exercises in Nim.
Nim
51
star
38

dart

Exercism exercises in Dart.
Dart
50
star
39

DEPRECATED.exercism.rb

DEPRECATED. See http://github.com/exercism/cli for the new CLI.
Ruby
48
star
40

DEPRECATED.x-api

Application to serve exercism assignments
Ruby
46
star
41

emacs-lisp

Exercism exercises in Emacs Lisp.
Emacs Lisp
45
star
42

docs

Exercism's docs. View them at Exercism's website, not on GitHub.
42
star
43

racket

Exercism exercises in Racket.
Racket
39
star
44

zig

Exercism exercises in Zig.
Zig
38
star
45

pony

Exercism exercises in Pony.
Pony
38
star
46

discussions

For discussing things like future features, roadmap, priorities, and other things that are not directly action-oriented (yet).
37
star
47

powershell

Exercism exercises in Windows PowerShell.
PowerShell
35
star
48

scheme

Exercism exercises in Scheme.
Scheme
35
star
49

purescript

Exercism exercises in PureScript.
PureScript
35
star
50

hiring-frontend-developer

34
star
51

pr-commenter-action

The PR Commenter GitHub action posts comments on a PR that can vary depending on which files are being changed in the PR.
JavaScript
33
star
52

lua

Exercism exercises in Lua.
Lua
33
star
53

pharo-smalltalk

Exercism exercises in Pharo.
Smalltalk
33
star
54

delphi

Exercism exercises in Delphi Pascal.
Pascal
33
star
55

exalysis

Mentoring tool for the Go track on Exercism. Downloads students code, checks it and provides suggestions.
Go
33
star
56

DEPRECATED.rikki

A worker written in golang for automatically nitpicking exercism submissions.
Go
30
star
57

idris

Exercism exercises in Idris.
Idris
29
star
58

plsql

Exercism exercises in PL/SQL.
PLSQL
28
star
59

prolog

Exercism exercises in Prolog.
Prolog
27
star
60

elixir-analyzer

Elixir
27
star
61

perl5

Exercism exercises in Perl 5.
Perl
26
star
62

automated-analysis

An overview space for Automated Analysis on Exercism
26
star
63

sml

Exercism exercises in Standard ML.
Standard ML
24
star
64

lfe

Exercism exercises in Lisp Flavoured Erlang (LFE).
LFE
23
star
65

r

Exercism exercises in R.
R
23
star
66

gui

JavaScript
22
star
67

deprecated-mentors

Rust
22
star
68

fortran

Exercism exercises in Fortran.
Fortran
22
star
69

x86-64-assembly

Exercism exercises in x86-64 Assembly.
Assembly
22
star
70

raku

Exercism exercises in Raku
Raku
22
star
71

blog

Exercism's blog content
Shell
21
star
72

configlet

The official tool for managing Exercism language track repositories.
Nim
20
star
73

reasonml

Exercism exercises in ReasonML.
Reason
20
star
74

groovy

Exercism exercises in Groovy.
Groovy
19
star
75

red

Exercism exercises in Red.
Red
19
star
76

mips

Exercism exercises in MIPS Assembly.
Shell
19
star
77

vimscript

Exercism exercises in Vim script.
Vim Script
18
star
78

generic-track

Ruby
18
star
79

coq

Exercism exercises in Coq.
Shell
17
star
80

nix

Exercism exercises in Nix.
Shell
17
star
81

terraform

HCL
17
star
82

DEPRECATED.help.exercism.io

DEPRECATED. LEGACY. NO LONGER BEING WORKED ON.
JavaScript
17
star
83

d

Exercism exercises in D.
D
16
star
84

v2-configlet

Tool to assist in managing Exercism language tracks.
Go
16
star
85

coffeescript

Exercism exercises in CoffeeScript.
CoffeeScript
16
star
86

development-environment

Ruby
16
star
87

solidity

Exercism exercises in Solidity.
JavaScript
15
star
88

babashka

Exercism exercises in Babashka.
Clojure
14
star
89

javascript-analyzer

This is Exercism's automated analyzer for the JavaScript track.
TypeScript
14
star
90

interactive-cli-walkthrough

Ruby
13
star
91

DEPRECATED.v2-feedback

Please use https://github.com/exercism/exercism.io for reporting issues
13
star
92

ruby-analyzer

This is Exercism's automated analyzer for the Ruby track.
Ruby
13
star
93

csharp-analyzer

An analyser for C#
C#
12
star
94

cfml

Exercism exercises in CFML.
ColdFusion
12
star
95

gnu-apl

Exercism exercises in GNU APL.
APL
12
star
96

v3-beta

12
star
97

awk

Exercism exercises in AWK.
Shell
12
star
98

tracks-maintenance-dashboard

A dashboard for maintainers to understand the state of tracks
TypeScript
11
star
99

python-test-runner

Python
11
star
100

go-test-runner

Jupyter Notebook
11
star