Systems-Level Design Group

Interpreter Utilities

Overview

We have developed two libraries for constructing composable, monadic interpreters in Haskell. The LangUtils library provides a collection of functions and type classes that implement semantic algebras in the style of Hutton and Duponcheel. LangUtils 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.

Building from the LangUtils library, the InterpreterLib library provides a similar capability that makes the algebra explicit. Instead of using the classic Haskell Algebra typeclass, the algebra is an explicit data structure. Interpreters are constructed in a similar fashion, but the semantic algebra is explicitly specified when constructing the interpreter.

The InterpreterLib package provides a small language for specifying and automatically generating boilerplate for explicit algebras. Also included is a collection of pre-defined standard AST elements that represent many common language constructs. If an AST construct is not available, the algebra compiler algc can be used to automatically generate necessary data structures and boilerplate from a simple interface specification.

More recent extensions include comonadic constructs allowing temporal ordering of execution. Composable, monadic techniques are used to write an interpreter for the behavioral aspects of a simulation. A comonad is chosen to represent temporal ordering of contexts based on simulation needs. The Id comonad results in a simple interpreter. The LVS comonad results in a simulator with capabilities for representing future and past environments. The Modular Comonadic Simulation Semantics below describes these additions.

Publications

Downloads

Sponsors

This work has been sponsored by an ITTC Technology Transfer Grant and a Cadstone R&D contract.

About Us | Site Map | Contact Us | ©2005 The University of Kansas