sLISP
is a pure-functional LISP
implementation in Haskell
.
Initially, it started as a simple S-expression parser to demonstrate how the 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.
- Based on
s
(plays all roles in theR
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)
$ 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
sLISP
REPL supports simple but some useful modes. Each mode is switched right after key input as shown below.
;; 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> ;;;;