Stupid Template Tricks: Brainfuck Compile Time Evaluator

Every 2nd grader knows that the C++ template system is Turing complete. So what? Compile time Brainfuck evaluator that's what! It turns out that I'm not the first person who learned me some metaprogramming and thought it would be a good laugh to implement Brainfuck with C++ templates. But in…

Stupid Template Tricks: Reversing Template Parameters on Templated Types

When I came across this Stack Overflow question about reversing a c++ std::tuple type, naturally I wondered if the same could be done to templated types besides std::tuple, i.e. for a templated type T, converting T<P1, P2, ..., Pn> to T<Pn, Pn-1, ..., P1…

Inlining in Khepri - Introduction

I designed Khepri with function inlining in mind, but inlining support was only recently added to the compiler. This post overviews the Khepri compiler's inlining support. A later post will cover some of the specific challenges of inlining Javascript and how Khepri implements inlining. The Need For Inlining The functional…

Incremental Parsing With Feedback in a Web Worker

I previously described running Bennu parsers incrementally. Here I show how we can offload incremental parsing to a web worker, and get realtime feedback as the worker parses data. Example Overview I'm going to develop a simple word count application that uses a Bennu parser run in a web worker…

Akh - Monad Transformers for Javascript

Akh is a small Javascript library of monad transformers and structures. This post briefly covers why monad transformers are useful in Javascript, and offers a very high level look at the monad transformer Akh offers and their interface. Why Monad Transformers are Useful in Javascript Even in untyped, non-functional language…

Khepri Slice Unpacks

Khepri V0.22 adds slice unpacks for unpacking a range of values to an array. Here I briefly cover slice unpacks. You can find the Khepri language documentation here. Rational Functions that take an arbitrary number of arguments are common in Javascript, but writing such variadic function is fairly confusing…