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
- Host: GitHub
- URL: https://github.com/almayor/ft_turing
- Owner: almayor
- License: bsd-3-clause
- Created: 2022-08-28T07:27:03.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-08T18:21:02.000Z (about 3 years ago)
- Last Synced: 2025-01-30T05:26:45.650Z (10 months ago)
- Topics: 21school, functional-programming, haskell, turing-machine
- Language: Haskell
- Homepage:
- Size: 1.28 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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