Skip to content

thyeem/slisp

Repository files navigation

sLISP

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.

Features

  • Based on 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

$ 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.

;; 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> ;;;;

Releases

No releases published

Packages

No packages published