Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aneeshdurg/lambda
A simple lambda calculus interpreter
https://github.com/aneeshdurg/lambda
haskell interpreter lambda-calculus parsec
Last synced: 19 days ago
JSON representation
A simple lambda calculus interpreter
- Host: GitHub
- URL: https://github.com/aneeshdurg/lambda
- Owner: aneeshdurg
- Created: 2017-05-29T16:59:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-08T22:15:32.000Z (over 7 years ago)
- Last Synced: 2024-11-29T02:34:38.294Z (3 months ago)
- Topics: haskell, interpreter, lambda-calculus, parsec
- Language: Haskell
- Size: 21.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lambda
A simple lambda calculus interpreterIn the interest of saving time and effort I lifted a lot of template code from MP6 of cs421 - write a scheme interpreter. You might find a lot of comments pertaining to the assignment, that are irrelevent to this project. I am working on removing those, but am more interesting in getting this to work well first.
### Usage
If you haven't installed stack:
```bash
curl -sSL https://get.haskellstack.org/ | sh
```
After you have stack,
```bash
stack init
```To run either use `stack build` to generate binaries or `stack repl` and type `main`.
### Syntax
#### Function application:
* function and arugments seperated by a space.
* functions will assume that all items to the left are arguments unless they are specified with parens or it encounters an infix binary operation (+*-/><)
```haskell
f x
g (f x) y
f x + 1
== (f x) + 1
```
#### Lambda functions:
* denoted by a \, arguments are seperated by spaces
* body and arguments delimited by a .
```haskell
\x y.x + y
\x.\y.y x
(\x.x x) (\x.x x)
```
#### Variable assignment:* Variables can only be assigned as a top level expression
```haskell
y = 1
x = (\x.x+y)
y = 3
x 2
== 3
y
== 3
```#### Numbers and Booleans
* Currently only integers are supported
```haskell
1, 2, #t, #f
(\x . 3 > x) 2
== #f
```#### Binary Operators
```haskell
1+2
== 3
5/3
== 1
1*1
== 1
1-1
== 0
1 > 1
== #t
1 < 1
== #t
```### TODO:
* ~~Implement logical operators~~
* ~~Implement equality operator~~
* Better show instances for types
* Tuples
* Pattern matching
* User-defined data types
* Various other things