Overview
The goal of this project to provide Haskell ports of all OCaml implementations for "Types and Programming Languages" (TAPL) by Benjamin C. Pierce.
Each directory (except for "common") contains a single implementation and corresponds the directory of the same name found under "Implementation" at TAPL.
Each Haskell implementation uses Parsec for parsing, and has an HUnit test suite.
Current Status
Complete through Chapter 19 (end of Part III) of TAPL.
- arith (Chapters 3 - 4)
- untyped (Chapters 5 - 7)
- fulluntyped (Chapters 5 - 7)
- tyarith (Chapter 8)
- simplebool (Chapter 10)
- fullsimple (Chapter 9 and 11)
- fullref (Chapters 13 and 18)
- fullerror (Chapter 14)
- fullsub (Chapters 15 - 17)
- rcdsubbot (Chapters 15 - 17)
- bot (Chapter 16)
In Progress
- fullisorec (Chapter 20)
- fullequirec (Chapter 20)
- equirec (Chapter 21)
To Do
- reconbase & recon & fullrecon(Chapter 22)
- fullpoly (Chapters 23 & 24)
- fullfsub (Chapter 26)
- fomsub & fullfomsub (Chapters 26, 30)
- fullfsubref (Chapter 27)
- purefsub & fullfsub (Chapter 28)
- fomega & fullomega (Chapters 23, 29, 30)
- fullupdate (Chapter 32)
- Exercises: letexercise & joinexercise
Code Generation
As I added ports for the different implementations, I realized that I was duplicating a lot of code. I abstracted some into common files, but when one of the main types would change slightly (e.g., a new type was added), I didn't know how to cleanly abstract across the different versions of the type. I considered Template Haskell, but I did not want to sacrifice readability of individual implementations.
I eventually settled on using code generation (see the 'generator' directory). In a config file, an implementation specifies sets of terms, types, tests, and other global options, and all of the necessary code is then generated in its 'gen' subdirectory. The generator itself is not pretty, but this approach allows the user to explore an individual implementation without suffering (too much) from abstractions that are not relevant to the code at hand. (Of course, any changes will be lost unless they are migrated to the generator.)
The code generator is currently very primitive, and only fullsimple and fullsub make use of it.
Notes
The code has only been tested using GHC 6.8 on Ubuntu.
Contributions and/or feedback are very much welcomed. Please contact Ryan W. Porter.