nw  

Functional Standard Library for the Kolibri Web UI Toolkit

Summary

This project extends the Kolibri UI Toolkit with a functional standard library. The library consists of two main parts: A new data structure called "sequence" allowing to process data in a declarative manner. Therefore, the implementation profits from the advantages of functional programming, such as lazy evaluation. The second part contains the implementation of monadic abstractions, which are known from the programming language Haskell. The implementation is characterised by the high-quality standards of the Kolibri Web UI Toolkit, so robustness and sustainability were the focus of the work.

Keywords
Goals

The Kolibri Web UI Toolkit is planned to be extended with a functional standard library, with a mandatory requirement for robust, sustainable, and efficient programming, ensuring proven usefulness for the developer. The achieved results will be demonstrated through small examples to showcase their usefulness.

Initial Situation

The FHNW collaborates with students to develop the Web UI Toolkit "Kolibri." This library incorporates abstractions, test support, and utilities for safe HTML/DOM handling. In the previous project, IP5, an initial version of a functional standard library for the toolkit, was designed. Now, the focus is exploring alternative implementation approaches offering more advantages. Following this, additional concepts based on the standard library will be examined, testing their usefulness and feasibility and implementing them where possible.

Results

The gained knowledge led to the development of a functional standard library comprising two main parts: The first part, called the "Sequence library", introduces the new data structure "sequence". This structure implements the JavaScript iteration protocols, enabling lazy evaluation. The Sequence library provides various operations to transform and evaluate sequences and other data structures that implement the iteration protocols, including JavaScript arrays. These operations are static functions and can be easily extended.


The second part focuses on adapting the Haskell type class "monad" into JavaScript. This was made possible by the knowledge from the Sequence library. The monadic API allows writing generic functions that can handle various data structures. The sequence, being a monad, already implements this API. Additionally, a new type called "JsonMonad" was created, enabling the processing of inconsistent JSON files using language-integrated queries. Automated unit tests ensure the correctness of these artifacts, with a testing table providing a structured approach to testing, including checking for unique properties and invariants.


An implementation of the game Tic tac toe demonstrates the usefulness of the library and the developed abstractions. To provide a computer controlled opponent, this game uses an algorithm based on lazy evaluated lists.

Tic tac toe Game

You can play against the computer in this game and try to win. If you want to know more about the implementation of the game or the work in general, please consult our documentation page.

Project Data
Project type: Computer Science Project 6
Project duration: 20.02.2023 bis 18.08.2023
Team size: 2 people
Effort in hours: 360 per person
Project Customer

University of Applied Sciences and Arts Northwestern Switzerland
Institute of Mobile and Distributed Systems
Prof. Dierk König
dierk.koenig@fhnw.ch

Project Team

Tobias Wyss - tobias.wyss@students.fhnw.ch
Andri Wild - andri.wild@students.fhnw.ch

Contact

Prof. Dierk König - dierk.koenig@fhnw.ch

<< zurück