README.md 2.15 KB
Newer Older
1
# Connect4
Marko Dimjašević's avatar
Marko Dimjašević committed
2
3
4

This is a connection board game implemented in Haskell.

5
## Running, Testing and Documentation
6

Marko Dimjašević's avatar
Marko Dimjašević committed
7
8
9
To run it locally on port 8080, run:

    stack run
10
11
12
13
14

To run tests, execute:

    stack test

15
16
17
18
19
20
21
22
23
24
25
To generate documentation from the annotated source code:

    stack haddock

To generate web API documentation, run:

    stack run

and then kill the process. This will generate API documentation in the `docs`
directory.

26
27
28
29
30
## Technology

There are lots of Haskell and programming language theory features that this
code base makes use of, to name a few:

31
32
33
34
35
36
37
38
39
- An eDSL for describing a web API, as provided by the Servant framework (see
  `src/WebAPI.hs`). Servant uses monad transformers for its central type
  family `ServerT` and for the `Handler` monad,
- An effect system as provided by the Polysemy library. The game uses
  several eDSLs for these effects: input, error handling, state
  updating in a concurrent application, random value generator and a
  key value store. This effect system is plugged in to Servant's monad
  transformers, which provides separation of domain logic from web server
  concerns.
40
41
- The code is structured in layers, where a layer has access only to
  functionality provided by itself or by lower-level layers. This
42
  allows for ease of testing and maintenance, and swapping a dependency
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  library,
- Function totality,
- Generalised algebraic data types,
- Type differentiation via the `newtype` declaration. This has already
  brought to light a few bugs during development.

## To do

There are several aspects where the implementation could be improved:

- The implementation currently features no frontend client. This is to be
  implemented in Haskell.
- The `Logic` module implements a dummy empty disc to signal for absence
  of a disc in a column position. This is to be redone such that there are
  only two disc colours and thereby make illegal states not representable.
- More tests are needed for the web API. It is not clear how to thread the
  state from one HTTP request to another.
- Fix-sized vectors should be used instead of unbounded lists in the game
  logic (the `Logic` module). This will reflect the constraints on the grid
  size in the code.