Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/novara754/mu
Untyped Lambda Calculus parser & evaluator.
https://github.com/novara754/mu
Last synced: 24 days ago
JSON representation
Untyped Lambda Calculus parser & evaluator.
- Host: GitHub
- URL: https://github.com/novara754/mu
- Owner: novara754
- License: mit
- Created: 2020-08-07T20:09:04.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-08T12:13:36.000Z (about 4 years ago)
- Last Synced: 2024-01-14T23:13:17.243Z (10 months ago)
- Language: Haskell
- Size: 20.5 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mu
Simple untyped (and soon simply typed) lambda calculus interpreter written in Haskell.
Features:
* Bound and free variables
* Abstractions (functions)
* Function application
* Aliases to name expressions so they don't have to be typed out over and over again
* "Evaluation" through alpha conversion and beta reduction## Grammar
```
input ::= expr (";" expr)*
expr ::= alias | application
alias ::= ALIASIDENT ":=" application
application ::= (term)* | "(" application ")"
term ::= variable | abstraction
variable ::= VARIDENT | ALIASIDENT
abstraction ::= ("\" | "λ") VARIDENT "." applicationVARIDENT ::= _any single lowercase letter_
ALIASIDENT ::= _any series of alpha numeric characters_
```Whitespace after any token is ignored.
Comments can be started with `--`.## Examples
```
> ID := \x.x -- The identity function.
\x.x
> ID a
a
> AND := \p.\q.p q p -- Boolean and.
\p.\q.p q p
> TRUE := \x.\y.x -- Boolean true.
\x.\y.x
> FALSE := \x.\y.y -- Boolean false.
\x.\y.y
> AND TRUE FALSE ; AND TRUE TRUE
\x.\y.y ; \x.\y.x
```## Building & Running
The project can be easily built using Cabal (install via `ghcup` on Linux):
```
$ cabal build
```
and can also be run using
```
$ cabal run
```This will launch a REPL in which Lambda Calculus expressions can be typed and evaluated.
The program REPL can be installed by using
```
$ cabal install
```
This way it can be executed from anywhere by just invoking the `mu` command.## License
Licensed under the [MIT License](./LICENSE).