Skip to content

Repository files navigation

hal

A Scheme interpreter in Haskell.

Features

  • Macro definitions with define-syntax and syntax-rules
  • A bare bones standard library
  • Syntax error messages with line and column numbers
  • Continuations with call/cc
  • Multiple values with values
  • Exact integers, rationals and floating point numbers
  • REPL with multi-line support

Builtins and standard library

NameKind
-procedure
*procedure
/procedure
+procedure
<procedure
<=procedure
=procedure
>procedure
>=procedure
absprocedure
andsyntax
appendprocedure
applyprocedure
atom?procedure
beginsyntax
boolean?procedure
call-with-valuesprocedure
call/ccprocedure
car .. caaaarprocedure
casesyntax
cdr .. cddddrprocedure
char?procedure
complex?procedure
condsyntax
cons*procedure
consprocedure
define-syntaxsyntax
definesyntax
displayprocedure
divprocedure
dump-heapprocedure
eq?procedure
equal?*procedure
eqv?*procedure
error*procedure
even?procedure
exact?procedure
expandprocedure
filterprocedure
fold-leftprocedure
fold-rightprocedure
ifsyntax
inexact?procedure
lambdasyntax
let*syntax
letsyntax
letrec*syntax
letrec*syntax
listprocedure
mapprocedure
maxprocedure
minprocedure
modprocedure
negative?procedure
newlineprocedure
notprocedure
null?procedure
number?procedure
odd?procedure
orsyntax
pair?procedure
positive?procedure
quotesyntax
rational?procedure
real?procedure
set!syntax
string?procedure
symbol?procedure
syntax-rules*syntax
valuesprocedure
voidprocedure
zero?procedure

*implementation not fully compliant with the r6rs standard.

Installation

Make sure stack is installed, then run:

stack install hal

This will generate a hal executable in the current directory.

Usage

hal [FILES...] [-i]
  • FILES: files to run
  • -i: interactive mode (implied when no files are given)

The global environment is initialized with the standard library before running the first file and is not cleared after running each file. That means all files are run as if they were one single top-level program. After running all files, the value of the last expression of the last file is displayed.

Examples

See the examples directory.

About

A Scheme interpreter in Haskell.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages