An open API service indexing awesome lists of open source software.

https://github.com/almayor/ft_turing

A Turing Machine simulator written in Haskell
https://github.com/almayor/ft_turing

21school functional-programming haskell turing-machine

Last synced: 8 months ago
JSON representation

A Turing Machine simulator written in Haskell

Awesome Lists containing this project

README

          

# `ft_turing` – a Turing Machine simulator written in Haskell

* A student project implementing a single-headed, singly-infinite-tape Turing machine in Haskell
* The goal is to
* parse a machine description ([example](machines/00-unary_sub.json))
* validate it
* run the machine and log all transitions
* For complete instructions please refer to [docs](https://github.com/fpetras/42-subjects/blob/master/ft_turing.en.pdf)

## Usage

To use the machine you need to have installed [Stack](https://docs.haskellstack.org/en/stable/install_and_upgrade/). You can then run

```sh
$ stack run
```
where
- `machine` is a file describing the machine
- `input` is a string of symbols, representing initial tape contents.

Alternatively, you can pull the corresponding [Docker image](https://hub.docker.com/repository/docker/almayor/ft_turing) or build your own using the provided Dockerfile.

```sh
$ docker pull almayor/ft_turing:latest # or docker build -t ft_turing .
$ docker run almayor/ft_turing:latest
```

## Machines

A few machines capable of executing simple programs can be found in `machines/`:

00-unary_sub – performs unary subtraction.

01-unary_add – performs unary addition.

02-palindrome – checks if the input is a palindrome.

03-lang-0n1n – checks if the input is a word in the language

04-lang-02n – checks if the input is a word in the language

## Acknowledgements

I'm grateful to the entire team behind [School 21](https://21-school.ru) for the opportunity to do these interesting projects. I also thank

* [Denis Moskvin](https://www.hse.ru/en/org/persons/223602533) for a superb course on functional programming using Haskell
* [Léonard Marques](https://github.com/keuhdall) for putting a [similar project](https://github.com/keuhdall/ft_turing) in the public domain; it helped me clarify some important points.
* creators of [AnsiToImg](https://github.com/FHPythonUtils/AnsiToImg) – a tool for converting ANSI terminal output to pretty images