Skip to content

A Haskell-to-C Compiler for a subset of Haskell, fully written in Haskell

License

Notifications You must be signed in to change notification settings

akatau/tiny-ghc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinyGHC

 _   _               ___         ___ 
| |_(_)_ __  _   _  / _ \ /\  /\/ __\
| __| | '_ \| | | |/ /_\// /_/ / /   
| |_| | | | | |_| / /_\\/ __  / /___ 
 \__|_|_| |_|\__, \____/\/ /_/\____/ 
             |___/                   

tinyGHC is a Haskell-to-C compiler for a subset of Haskell (that I call tinyHaskell), fully written in Haskell.

The main objective of this project is to force myself to learn about or unlock many "mystery boxes" with one stone. These "mystery boxers" mainly are:

  1. Haskell: Doing a big project in Haskell should make me better at writing Haskell code (and, maybe, though not immediately obvious, in other imperative languages as well) and see the differences between it and other languages from the other paradigms (like Java and C++).
  2. Programming Languages: Understanding how programming languages work by implementing one myself—maybe even a Turing-complete one. Implementing a functional one adds more fun to it because implementing a functional language is rarely explained in the literature. Therefore, I am forced to read a few papers.
  3. Lexers.
  4. Parsers.
  5. Type-checkers.
  6. Code Generations.
  7. Garbage Collection

What subset of Haskell?

  • Conditional expressions
  • If then else expression
  • Multiple function heads with multiple patterns
  • Type Synonyms
  • Strings
  • Algebraic Data Types
  • Where expressions
  • Let expressions
  • Arithmetic operations
  • Arithmetic operations
  • Case expressions

TODO

  1. CLI Abstraction
  2. Lexer
  3. Parser
  4. Type-checker
  5. AST Simplifier
  6. Spinless Tagless G-machine Intermediate Representation
  7. C minus minus (C--) Intermediate Representation
  8. C Code Generation
  9. Garbae Collection

Resources

  1. Peyton Jones, S. L. (1987). The implementation of functional programming languages (prentice-hall international series in computer science). Prentice-Hall, Inc..
  2. Jones, S. L. P. (1993). Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine Version 2.5.
  3. Jones, S. L. P., & Lester, D. R. (2000). Implementing Functional Languages: a tutorial. Department of Computer Science, University of Glasgow.
  4. Jones, S. P., Hall, C., Hammond, K., Partain, W., & Wadler, P. (1993, July). The Glasgow Haskell compiler: a technical overview. In Proc. UK Joint Framework for Information Technology (JFIT) Technical Conference (Vol. 93).
  5. Peyton Jones, S. L., & Salkild, J. (1989, November). The spineless tagless G-machine. In Proceedings of the fourth international conference on Functional programming languages and computer architecture (pp. 184-201).
  6. Jones, S. P., Ramsey, N., & Reig, F. C--: a portable assembly language that supports garbage collection.
  7. Hutton, G., & Meijer, E. (1996). Monadic parser combinators.

Relevant Docs & Reports 1

  1. Seminar Report (for college)
  2. Seminar Presentation (for college)
  3. Project-Based Learning Report (still a draft)

Footnotes

  1. Markdown files are Obsidian-flavored markdown.

About

A Haskell-to-C Compiler for a subset of Haskell, fully written in Haskell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published