Advanced Functional Programming - Group project (2020)
Minesweepskell is a web implementation of the widely known video game Minesweeper fully written in the functional programming language Haskell.
Yesod
frameworkYesods
shakespearean templating systemTVars
TVars
, which provide mutability as well as atomic writing operationsPersistent
& MongoDB
Persistent
library to connect a MongoDB
Lenses
lenses
are used for almost all operations on data typesmatrix-lens
package and provide elegant manipulation of cells on the game boardMonads
Monads
are widely used throughout the project, especially the IO monad for things like state manipulation, as well as Yesods Handler Monad for the REST API, own Monads are not definedState
monad, but we could not get it to work in combination with Yesods handler monad. Due to this we switched to TVars for the global in-memory state, which proved to be a better choice, since it even provides atomic writing operations and was astonishingly smooth to implement for our use cases.Run in the project folder stack build
.
$ stack --version
Version 2.3.3 x86_64
$ yesod version
yesod-bin version: 1.6.0.6
# - if it fails run `xcode-select --install before`
brew install haskell-stack
stack install yesod-bin --install-ghc
# ~/.zshrc
export PATH=$HOME/.local/bin:$PATH
If you have trouble, refer to the Yesod Quickstart guide for additional detail.
brew tap mongodb/brew
brew install mongodb-community@4.4
brew services start mongodb-community@4.4
brew services stop mongodb-community@4.4
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/
stack build && stack exec -- yesod devel
to run the project locally.
stack build
stack exec -- yesod devel
, it watches for changes and recompiles the project automatically.stack clean --full && stack build
to clean the project and to rebuild it.~/.ghc/ghci.conf
:set prompt λ:
:set prompt-cont λ|
https://stackoverflow.com/a/47694134
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).
yesod
mongodb
persistent
lens
matrix-lens
...
For more details take a look at the package.yaml.
Along with the IntelliJ plugin for Haskell Ormolu is used as automatic code formatter.
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.