Gotta Monomorphize Em All

As a functional programming language, Juniper supports the primary feature of any functional language - first class functions. Since Juniper targets Arduino compatible systems that have minimal amounts of RAM, we would like to avoid heap allocations. Indeed, if you look at recommendation guides for embedded system programming, you will find that heap allocation shouldn’t be used or minimized. This poses a conundrum for language designers that want to support first class functions, since in most language implementations the closures of first class functions are allocated on the heap. The std::function wrapper in C++ does this, which is obviously not ideal.

Read More

Written Proof of Work

Large language models are already disrupting many areas of written work such as education, news stories and book publishing. The implications for education are obvious - students can cheat on essay writing by simply offloading all the hard work to the computer. Classical plagiarism checking tools are useless, and textual style of writing can be changed with a little prompt engineering. The story in book publication is just as troubling - a book on Amazon covering the recent Maui, Hawaii fires was published before the fires themselves were even over. Just today I saw an article about fake AI written mushroom identification books which could plausibly lead to injury or death.

Read More

Monad Tutorial

Here is my version of “yet another monad tutorial”. In this tutorial I will not cover specific examples of Monad implementations in detail since I think that this distracts from the goal of understanding the overall abstraction. I will also not cover some of the simpler type classes such as Functor and Monoid in detail, since these aren’t really that important for understanding Monad.

Read More

Continuous Approximations of Logical Functions

Logical functions are critical parts of almost every computer program. However, optimization problems are often solved over the set of real numbers, which does not fit nicely into this rigid binary logic. In many cases, we’d like to take advantage of applying logical operations, which includes their use in things like deep neural networks. How to describe these discrete functions in terms of a continuous function seems challenging. In this post I will show how we can apply the rules of logic to arrive at concise functions.

Read More

Type Inference by Solving Constraints

Type inference is used in functional programming languages to automatically deduce the type of expressions based on how the expression is used. Inference reduces the burden on the programmer who would otherwise have to write all the types manually. Anyone who uses an imperative statically typed programming language knows how quickly explicit type annotations can become burdensome. Type inference is slowly permeating non-functional languages such as C++ and C#, which widens the potential use of inference.

Read More