Overview
We have developed a library for constructing composable,
monadic interpreters in Haskell. The InterpreterLib
library provides a collection of functions and type classes that
implement semantic algebras in the style of Hutton and
Duponcheel.
InterpreterLib structures
interpreters around a Functor and Algebra written
for each AST construct. AST elements are defined
non-recursively and composed using a Sum type. The actual
language is formed by taking the least fixed point of the
language Sum. To interpret and AST element, a general
catamorphism is applied using Haskell's typeclass system to
select an appropriate algebra for interpreting each element.
Use the Haddock documentation for
InterpreterLib for reference.
The AST Builder executable provides a compiler
for a small language for specifying regular languages (not yet
released). The compiler output consists of Haskell modules of
boilerplate for functors and their algebras.
The Algebra Compiler (algc) defines a language
and compiler for defining boilerplate for semantic algebras.
algc is not required to use InterpreterLib, but is highly useful
for defining semantic algebras over InterpreterLib structures.
Also included is TermLib, a collection of
pre-defined standard AST elements that represent many common
language constructs (not yet released). If an AST construct is
not available, the AST Builder
astbuilder can be used to automatically
generate necessary data structures and boilerplate from a simple
interface specification.
Sponsors
This work has been sponsored by an ITTC Technology Transfer Grant
and a Cadstone R&D contract.