Pure Functional Game Engine using Haskell
EC 8206 – Functional Programming
- Member 1 – EG/2020/4056 - Madugalle E.W.M.W.W.N.D.B
- Member 2 – EG/2020/4078 - Morawaliyadda M.G.H.S.M
- Member 3 – EG/2020/4228 - Thanapathi T.M.I.U.B
- Member 4 – EG/2020/4289 - Wijebandara P.A.I
This project implements a pure functional game engine backend using Haskell.
It exposes a REST API that supports three classic games:
- Number Guessing Game
- Tic Tac Toe
- Hangman
The system demonstrates how functional programming principles such as purity, immutability, algebraic data types, and modular design can be used to build reliable and maintainable application logic, especially for state-driven systems like games.
game-engine/
├── Main.hs
├── ApiTypes.hs
├── DataTypes.hs
├── Processing.hs
├── IOHandler.hs
├── Utils.hs
├── game-engine.cabal
├── package.yaml
├── stack.yaml
└── README.md
- Haskell (GHC / Stack)
- Scotty (REST framework)
- Aeson (JSON serialization)
- wai-cors (CORS handling)
stack clean
stack build
stack run
Server starts at:
http://localhost:3001
POST /guess
POST /ttt/move
POST /hangman/guess
- Pure functions
- Immutability
- Algebraic Data Types (ADTs)
- Pattern matching
- Modular design
This project demonstrates the effectiveness of functional programming in Haskell for building reliable backend systems with clear state transitions and strong correctness guarantees.
Open https://game-fp-game-ui.nqmggx.easypanel.host/ with your browser to see the UI.