ndrsllwngr / ffp

Minesweepskell - a fun(ctional) Web Minesweeper written in Haskell. Advanced Functional Programming - Group project (2020)
https://www.tcs.ifi.lmu.de/lehre/ss-2020/fun
4 stars 0 forks source link
haskell minesweeper tailwind yesod

Minesweepskell - a fun(ctional) Web Minesweeper written in Haskell

Haskell CI

Advanced Functional Programming - Group project (2020)

Description

Minesweepskell is a web implementation of the widely known video game Minesweeper fully written in the functional programming language Haskell.

Features

landingpage game

Architecture

Web application with the Yesod framework

Global mutable in-memory state with TVars

Database with Persistent & MongoDB

Elegant data accessing/manipulation with Lenses

Utilisation of Monads

Installation

Run in the project folder stack build.

Requirements

$ stack --version
Version 2.3.3 x86_64

$ yesod version
yesod-bin version: 1.6.0.6

Install Haskell and Yesod

  1. Install haskell-stack and yesod
# - if it fails run `xcode-select --install before`
brew install haskell-stack
stack install yesod-bin --install-ghc
  1. Add yesod installation path to your shell
# ~/.zshrc
export PATH=$HOME/.local/bin:$PATH

If you have trouble, refer to the Yesod Quickstart guide for additional detail.

Install MongoDB

  1. Install MongoDB
brew tap mongodb/brew
brew install mongodb-community@4.4
  1. Run MongoDB
brew services start mongodb-community@4.4
brew services stop mongodb-community@4.4
  1. Verify that it is running ps aux | grep -v grep | grep mongod, logs can be found here /usr/local/var/log/mongodb/mongo.log. and settings here /usr/local/etc/mongod.conf

For more information take a look at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

  1. Use MongoDB Compass as GUI

Usage

stack build && stack exec -- yesod devel to run the project locally.

Development

Adjust GHC prompt
:set prompt      λ:
:set prompt-cont λ|

https://stackoverflow.com/a/47694134

Tests

stack test --flag minesweepskell:library-only --flag minesweepskell:dev

(Because yesod devel passes the library-only and dev flags, matching those flags means you don't need to recompile between tests and development, and it disables optimization to speed up your test compile times).

Dependencies (excerpt)

yesod
mongodb
persistent
lens
matrix-lens
...

For more details take a look at the package.yaml.

Code formatting

Along with the IntelliJ plugin for Haskell Ormolu is used as automatic code formatter.

Contributors

Individual contributions

Due to the small group size of 3 it is impossible for us to properly distinguish what of our project has been done by whom. We all worked on all parts of our application, especially since we mostly did “pair-programming” (with two or often all three of us working together). So all of us were equally involved in all parts of our application. We would be happy to answer questions about our development process, as well as our individual/collective contributions at the examination.