Skip to content
A self-hosting mini Haskell compiler with a mini C runtime.
Haskell C Shell Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
.travis.yml Activate travis CI Nov 25, 2019
LICENSE Add compiler binary Nov 21, 2019
Makefile
README.md Comment parsers with BNF notation Dec 11, 2019
blynn.c
check.sh Raise timeout time to 60 to fix Travis build Dec 3, 2019
check_compile.sh Raise timeout time to 60 to fix Travis build Dec 3, 2019
classy Make debruijn total, add bignum demo Dec 6, 2019
classy.hs
default.nix Add Nix build file Nov 25, 2019

README.md

A compiler for a subset of Haskell to Combinatory Logic

Build Status

Adapted from the original version by Ben Lynn

This is an elaboration and annotation of Ben Lynn's Haskell compiler and C VM. The main aim is to improve upon the compiler, in various layers (see Future plans).

Usage

./blynn <binary> <input> <output>

Where binary is the combinatory logic program to run, input is the file whose contents are passed to the binary, and output is the file to write the output to.

Building

Requirements

  • A C compiler and make. That's it!

Testing

To check self-compilation, run ./check.sh classy.hs. It does the following:

  • Run classy (compiler binary) on classy.hs (compiler source), producing classy2
  • Run classy2 on classy.hs, producing classy3
  • Check that classy2 and classy3 are identical.

If you've made a change to what classy.hs outputs, (e.g. an optimization to code generation), run ./check_compile.sh classy.hs instead. It adds another step to the same process in check.sh to ensure that the changes propagate.

Future plans

Bootstrapping

  • Create bootstrapping path from original classy compiler

C runtime

  • Monadic I/O
    • putc, getc, filesystems
  • Alternate VM in Forth?

Compiler

Initial phase; parsing and totality, then reduce heap usage.

  • Use more typeclasses in this compiler
  • Remove undefined, only use total functions
  • "Don't pay for what you don't use" (only emit code for functions referenced from main)
  • Convert to CPS and perform partial evaluation

Parser

  • Rewrite in applicative style with typeclasses
  • Add block comments
  • Use Parsec-style parsing
  • Better parser error messages
    • Need show instance for Msg
  • do-notation

Types

  • Separation of Char and Int types
  • Add more types to the standard prelude
  • Allow class constraint in class declaration like (class Functor f => Applicative f where ...)
  • Multi-parameter typeclasses
  • Dependent/linear types?
You can’t perform that action at this time.