Joseph Morag

Micro C, Part 4: Integrating the LLVM FFI

https://blog.josephmorag.com/posts/mcc4/ 2020-05-13
In our last post, we completed the backend stage of the compiler by emitting llvm assembly using llvm-hs-pure and llvm-hs-pretty and then calling clang on the file output. Here, we'll get a taste of how to use the ffi bindings in llvm-hs to do the same thing and also to perform stricter checks on our generated llvm code.

Micro C, Part 3: Generating LLVM

https://blog.josephmorag.com/posts/mcc3/ 2020-04-17
In part 2, we completed the user facing part of the compiler with semantic analysis. Now we're free to focus on the backend, generating LLVM. To do so, we'll use the llvm-hs-pure library, which embeds LLVM into a Haskell ADT, allowing us to manipulate it without having to set up any FFI.

Micro C, Part 2: Semantic Analysis

https://blog.josephmorag.com/posts/mcc2/ 2020-04-15
Having written the parser for our C dialiect in part 1, we now proceed to the semantic analysis pass. Here, our goal is to catch as many errors as possible before going on to code generation. In particular, we will be somewhat stricter than real C compilers and disallow implicit conversions because they are both annoying to implement and lead to subtle bugs.

Micro C, Part 1: Parsing

https://blog.josephmorag.com/posts/mcc1/ 2020-04-10
Welcome to the beginning of the compiler proper! If you haven't yet, check out part 0 for a description of the project and help setting up the development environment. A note about the presentation structure: We will be going through each phase of the compiler mostly in its entirety before moving onto the next phase.

Micro C, Part 0: Introduction

https://blog.josephmorag.com/posts/mcc0/ 2020-04-08
In this series, we will explore how to write a compiler for a small subset of C to LLVM in Haskell. Our language, Micro C, is basically a small subset of real C. We'll have basic numeric types, a real bool type, pointers, and structs. At the end of the series, we'll have a beautiful executable, mcc (Micro C Compiler), that takes one .

HJKL and Colemak

https://blog.josephmorag.com/posts/hjkl/ 2020-03-27
I am a proud owner of both the Atreus and Keyboardio Model01 keyboards. They are both excellent pieces of hardware - wooden enclosures, mechanical switches, the works. With QMK, they are infinitely configurable. The creators are also very responsive. In the course of replacing the Matias Quiet Click switches with linear ones on my Atreus, I broke a couple keycaps and shorted part of the PCB.

Zipping Trees, Part 2

https://blog.josephmorag.com/posts/zip-tree2/ 2020-03-23

In part 1 of our tree zipping series, we identified three "problems" with our solution:

Zipping Trees, Part 1

https://blog.josephmorag.com/posts/zip-tree1/ 2020-03-20

While trawling hackerrank in order to procrastinate doing "real" work, I came across this problem in the Functional Programming section. It has you perform various incremental operations on a rose tree, such as inserting and deleting nodes and visiting adjacent nodes in the tree. In the spirit of sticking with Simple Haskell, our first attempt at the problem will use only one benign language extension and two imports.