Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skyf0l/hal
Epitech - A Lisp interpreter in Haskell
https://github.com/skyf0l/hal
haskell interpreter lisp lisp-interpreter parser r6rs r6rs-scheme scheme scheme-interpreter
Last synced: 11 days ago
JSON representation
Epitech - A Lisp interpreter in Haskell
- Host: GitHub
- URL: https://github.com/skyf0l/hal
- Owner: skyf0l
- License: bsd-3-clause
- Created: 2021-11-29T15:32:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-29T19:54:26.000Z (about 3 years ago)
- Last Synced: 2024-11-28T00:42:53.235Z (2 months ago)
- Topics: haskell, interpreter, lisp, lisp-interpreter, parser, r6rs, r6rs-scheme, scheme, scheme-interpreter
- Language: Haskell
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HAL
A lisp interpreter in Haskell based on [r6rs](http://www.r6rs.org/)
By [@skyf0l](https://github.com/skyf0l) and [@pebloop](https://github.com/pebloop)
# Notes
| Category | Percentage | Tests |
| ------------------- | ---------- | --------- |
| 01 Basics | 100% | 3/3 |
| 02 Quote | 100% | 2/2 |
| 03 Cons Car Cdr | 100% | 5/5 |
| 04 Arithmetics | 100% | 3/3 |
| 05 Equalities | 100% | 5/5 |
| 06 Define | 100% | 2/2 |
| 07 Conditionals | 100% | 3/3 |
| 08 Lambda | 100% | 3/3 |
| 09 Complex programs | 100% | 5/5 |
| 10 Error handling | 100% | 4/4 |
| 99 Coding style | 100% | 3/3 |
| **End scores** | **100%** | **38/38** |# Features
- Builtins
- Basics (car, cdr, cons, void, ...)
- Predicates (eq?, null?, number?, pair?, ...)
- Arithmetic (+, -, \*, div, mod, min, max, even?, odd?, pow, sum, product, ...)
- Comparisons (<, >, <=, >=)
- String comparison (string=?, string, string<=?, string>?, string>=?)
- List functions (length, append, reverse, map, filter, foldl, foldr, ...)
- Algorithms (fibonacci, factorial, merge-sort)
- IO (display, newline)
- Load library (load)
- Forms
- Cond
- If
- Let
- Lambda
- Quote
- Set
- Define
- Begin
- REPL
- Read-eval-print loop (interactive)
- Debug commands (show expression in datums / forms)
- Environment commands (show, enter, leave, clear)# Usage
```
$ ./hal --help
Usage: ./hal [FILE]... [OPTION]...
-h --help Show this help and exit
-q --quiet Suppress prompt
-i --interactive Enable interactive mode
-l FILE/DIR PATH --library=FILE/DIR PATH Add a library path
```# Demo
```lisp
$ ./hal
HAL - Lisp REPL
Type :h to see help
Type :q to quit> (define add (lambda (a b) (+ a b)))
> add
#
> (add 40 2)
42
> (set! add 42)
> add
42
> (fib 21)
10946
> (merge-sort '(39 16 22 24 17 29 18 26 27 3 34 25 10 6 7 12 8 30 2 21 13 36 14 38 32 41 40 4 35 19 5 33 23 9 15 31 28 20 42 37 11 1))
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42)
```# Build
```
$ make
```or
```
$ stack build --copy-bins
```# Tests
```
$ make tests_run
```or
```
$ ./tests.sh
```