All Projects → siraben → Mini Haskell

siraben / Mini Haskell

Licence: mit
A self-hosting mini Haskell compiler with a mini C runtime.

Programming Languages

c
50402 projects - #5 most used programming language
haskell
3896 projects

Projects that are alternatives of or similar to Mini Haskell

Dugong
Minimal State Store Manager for React Apps using RxJS
Stars: ✭ 10 (-72.97%)
Mutual labels:  compiler
Rum
💀 Compiler for the Rum language
Stars: ✭ 21 (-43.24%)
Mutual labels:  compiler
Zion
A statically-typed strictly-evaluated garbage-collected readable programming language.
Stars: ✭ 33 (-10.81%)
Mutual labels:  compiler
Potterscript
/x/pel/e/r/mus
Stars: ✭ 12 (-67.57%)
Mutual labels:  compiler
Asl
Arma Scripting Language - a clean scripting language compiling to Arma 3 SQF scripts.
Stars: ✭ 20 (-45.95%)
Mutual labels:  compiler
Sml Compiler
A compiler for Standard ML, somewhat
Stars: ✭ 22 (-40.54%)
Mutual labels:  compiler
Shivyc
C compiler created in Python.
Stars: ✭ 845 (+2183.78%)
Mutual labels:  compiler
Rustiny
A Rust-like language compiling to x86-64 assembler
Stars: ✭ 34 (-8.11%)
Mutual labels:  compiler
Parsel
Create complex parsers by combining simple ones with Parsel!
Stars: ✭ 21 (-43.24%)
Mutual labels:  parser-combinators
Parsley
An exceptionally fast parser combinator library for Scala
Stars: ✭ 31 (-16.22%)
Mutual labels:  parser-combinators
Kaleidoscope
Haskell LLVM JIT Compiler Tutorial
Stars: ✭ 870 (+2251.35%)
Mutual labels:  compiler
Rexjs
Rexjs is a faster and smaller JavaScript(ES6+) compiler!
Stars: ✭ 15 (-59.46%)
Mutual labels:  compiler
Wasp
A programming language that understands what a web app is.
Stars: ✭ 940 (+2440.54%)
Mutual labels:  compiler
Parsec.js
A JavaScript parser combinator library inspired by Parsec of Haskell.
Stars: ✭ 12 (-67.57%)
Mutual labels:  parser-combinators
Unlisp Llvm
Compiler for a toy Lisp language
Stars: ✭ 33 (-10.81%)
Mutual labels:  compiler
Lyca
programming language compiler w/ llvm
Stars: ✭ 9 (-75.68%)
Mutual labels:  compiler
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (+2364.86%)
Mutual labels:  parser-combinators
Compcert
The CompCert formally-verified C compiler
Stars: ✭ 984 (+2559.46%)
Mutual labels:  compiler
Mooncraft
Lua to Commandblock compiler
Stars: ✭ 33 (-10.81%)
Mutual labels:  compiler
Write A Programming Language
How to make a new language(and why we shouldn't?)
Stars: ✭ 29 (-21.62%)
Mutual labels:  compiler

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).

Features

  • Valid subset of Haskell! Code works on GHC as long as you have curly braces and delimiters as needed (see classy.hs)
  • Type inference, type classes, algebraic data types
  • Pure! The last function defined should be a function of type String -> String, which will receive input from stdin and whose output will be printed to the console
  • VM (~350 SLOC) is written in ANSI C and works on 32 and 64-bit systems
  • Compiles to combinatory logic (CL), evaluation proceeds via graph reduction

Usage

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

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

Building

Requirements

  • An ANSI 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
    • [ ] Combinators should take a continuation, doing I/O then passing the result to the continuation
  • [ ] Alternate VM in Forth?

Compiler

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

  • [x] 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

  • [x] Rewrite in applicative style with typeclasses
  • [x] Add block comments
  • [x] Use Parsec-style parsing
  • [ ] Better parser error messages
    • [ ] Writer 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?
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].