husk-scheme: R5RS Scheme interpreter, compiler, and library.

[ compilers-interpreters, language, library, mit, program ] [ Propose Tags ]

A dialect of R5RS Scheme written in Haskell. Provides advanced features including continuations, hygienic macros, a Haskell FFI, and the full numeric tower.


[Skip to Readme]

Modules

[Last Documentation]

  • Language
    • Scheme
      • Language.Scheme.Compiler
      • Language.Scheme.Core
      • Language.Scheme.FFI
      • Language.Scheme.Macro
        • Language.Scheme.Macro.Matches
      • Language.Scheme.Numerical
      • Language.Scheme.Parser
      • Plugins
        • Language.Scheme.Plugins.CPUTime
      • Language.Scheme.Primitives
      • Language.Scheme.Types
      • Language.Scheme.Variables

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0, 1.1, 1.2, 1.3, 2.0, 2.1, 2.2, 2.3, 2.4, 3.0, 3.1, 3.2, 3.2.1, 3.3, 3.4, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.5.1, 3.5.2, 3.5.2.1, 3.5.2.2, 3.5.2.3, 3.5.3, 3.5.3.1, 3.5.3.2, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.6, 3.6.1, 3.6.2, 3.6.3, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14, 3.15, 3.15.1, 3.15.2, 3.16, 3.16.1, 3.17, 3.17.1, 3.18, 3.19, 3.19.1, 3.19.2, 3.19.3, 3.20
Dependencies array, base (>=2.0 && <5), containers, directory, filepath, ghc, ghc-paths, haskeline, haskell98, husk-scheme, mtl, parsec, process, transformers [details]
License MIT
Author Justin Ethier
Maintainer Justin Ethier <github.com/justinethier>
Category Compilers/Interpreters, Language
Home page http://justinethier.github.com/husk-scheme
Source repo head: git clone git://github.com/justinethier/husk-scheme.git
Uploaded by JustinEthier at 2012-02-05T17:47:33Z
Distributions
Reverse Dependencies 3 direct, 0 indirect [details]
Executables huskc, huski
Downloads 38332 total (88 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-12-25 [all 7 reports]

Readme for husk-scheme-3.5.2

[back to package description]

husk Scheme

husk is a dialect of Scheme written in Haskell that adheres to the R5RS standard. Advanced R5RS features are provided including continuations, hygienic macros, and a full numeric tower.

husk may be used as either a stand-alone interpreter or as an extension language within a larger Haskell application. By closely following the R5RS standard, the intent is to develop a Scheme that is as compatible as possible with other R5RS Schemes. husk is mature enough for use in production applications, however it is not optimized for performance-critical applications.

Scheme is one of two main dialects of Lisp. Scheme follows a minimalist design philosophy: the core language consists of a small number of fundamental forms which may be used to implement other built-in forms. Scheme is an excellent language for writing small, elegant programs, and may also be used to write scripts or embed scripting functionality within a larger application.

Feature List

husk includes most features from R5RS, including:

  • Primitive data types and their standard forms, including string, char, numbers (integer, rational, floating point, and complex), list, pair, vector, and symbols
  • Proper tail recursion
  • Proper lexical scoping
  • Conditionals: if, case, cond
  • Sequencing: begin
  • Iteration: do
  • Quasi-quotation
  • Delayed Execution: delay, force
  • Binding constructs: let, named let, let*, letrec
  • Assignment operations
  • Basic IO functions
  • Standard library of Scheme functions
  • Read-Eval-Print-Loop (REPL) interpreter, with input driven by Haskeline to provide a rich user experience
  • Full numeric tower: includes support for parsing/storing types (exact, inexact, etc), support for operations on these types as well as mixing types and other constraints from the R5RS specification.
  • Continuations: First-class continuations of unlimited extent, call/cc, and call-with-values.
  • Hygienic Macros: High-level macros via define-syntax, let-syntax, and letrec-syntax - Note this is still somewhat of a work in progress - Macro support has improve significantly in the last few releases, and it works well enough that almost all derived forms are implemented as macros in our standard library, but you may still run into problems when defining your own macros.

As well as the following approved extensions:

  • Hash tables, as specified by SRFI 69

And the following R7RS draft features:

  • Nested block comments using #| and |#

Installation

husk may be installed using cabal - just run the following command:

cabal install husk-scheme

Usage

The interpreter may be invoked by running it directly from the command line:

./huski

Alternatively, you may run an individual scheme program:

./huski my-scheme-file.scm

API

A Haskell API is also provided to allow you to embed a Scheme interpreter within a Haskell program. The key API modules are:

  • Language.Scheme.Core - Contains functions to evaluate (execute) Scheme code.
  • Language.Scheme.Types - Contains Haskell data types used to represent Scheme primitives.

For more information, run make doc to generate API documentation from the source code. Also, see shell.hs for a quick example of how you might get started.

Foreign Function Interface

A foreign function interface (FFI) is provided to allow husk to call into arbitrary Haskell code. The interface is currently available via the load-ffi function:

(load-ffi "Language.Scheme.Plugins.CPUTime" "precision" "cpu-time:precision")

load-ffi accepts the following string arguments:

  • Name of a Haskell module to dynamically load
  • Haskell function to load from that module
  • Name to use for the function after it is loaded into husk

From the previous example, once cpu-time:precision is loaded, it may be called directly from husk just like a regular Scheme function:

(cpu-time:precision)

Any Haskell function loaded via the FFI must be of the following type:

[LispVal] -> IOThrowsError LispVal

See husk's Language.Scheme.Plugins.CPUTime module for an example of how to use the husk FFI.

Development

The following packages are required to build husk scheme:

  • GHC
  • cabal-install may be used to build, deploy, and generate packages for husk.
  • Haskeline - which may be installed using cabal: cabal install haskeline

The tests directory contains unit tests for much of the scheme code. All tests may be executed via the make test command.

The examples directory contains example scheme programs.

Patches are welcome! Please send them via a pull request on github. Also, when making code changes please try to add at least one test case for your change, and ensure that the change does not break any existing unit tests.

License

husk scheme is available under the MIT license.

Credits

husk scheme is developed by Justin Ethier.

The interpreter is based on code from the book Write Yourself a Scheme in 48 Hours written by Jonathan Tang and hosted / maintained by Wikibooks.

If you would like to request changes, report bug fixes, or contact me, visit the project web site at GitHub.