https://github.com/thyeem/slisp
A LISP written in Haskell
https://github.com/thyeem/slisp
language lisp lisp-dialect
Last synced: 7 months ago
JSON representation
A LISP written in Haskell
- Host: GitHub
- URL: https://github.com/thyeem/slisp
- Owner: thyeem
- License: mit
- Created: 2022-10-27T02:27:38.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-26T18:48:20.000Z (almost 2 years ago)
- Last Synced: 2024-03-26T19:52:49.450Z (almost 2 years ago)
- Topics: language, lisp, lisp-dialect
- Language: Haskell
- Homepage:
- Size: 10.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# sLISP
`sLISP` is a pure-functional `LISP` implementation in `Haskell`.
Initially, it started as a simple _S-expression_ parser to demonstrate how the [`s`](https://github.com/thyeem/s) nicely works, but decided to go a little more.
I hope that this **1k+ lines of code** will be one of the simplest and _the most readable LISP implementation_ compared to capability it has.
## Features
- Based on [`s`](https://github.com/thyeem/s) (plays all roles in the `R` part in the REPL)
- Pure-functional (_NO reference object used like `IORef`_)
- Coded with a very few principles and patterns
> each bind (`>>=`) exactly corresponds to a single state transition
- Almost compatible with `CLISP` main built-in functions (in progress)
## Build
```bash
$ git clone https://github.com/thyeem/slisp
# build: this yields ~80kB binary 'sl'
$ stack build
# run sLISP REPL
$ stack run
# test
$ stack test
# documentation
$ stack haddock --open slisp
```
## Demo

## REPL
`sLISP` __REPL__ supports simple but some useful modes. Each mode is switched right after key input as shown below.
```lisp
;; one semicolon -> paste-mode (multi-line input)
sLISP> ;
;; two semicolons -> debug-mode (describe S-expression with hierarchical structure)
sLISP> ;;
;; three semicolons -> view the REPL environment (symbol-data map)
sLISP> ;;;
;; four semicolons -> list all built-in functions
sLISP> ;;;;
```