Higher Order Primitves

27 December 2020 - 3 January 2021 — Bryan Mehall

Since the last post I tried making a quadtree as a demo and the workflow is actually pretty close to done. The main features missing are the ability to map / filter / reduce arrays. It's not required but it would be nice to add the ability to automatically calculate isomorphisms between dependencies that should all work together. For example, a rectangle with rectangle.bottom = rectangle.top + rectangle.height should also imply that rectangle.top = rectangle.bottom - rectangle.height and the type constraints should also be self-consistent. That is a discussion for another blog post. The main focus of this post is the implementation of map / filter / reduce.

The problem with how these higher order functions are implemented right now is that there is no distinction in the primitives between functions and function application. The map function takes two arguments: an array of lynx expressions and a function that is mapped over these functions. one possibility of this function is the getValue function to evaluate an attribute for every element in the array. Right now, getValue is only implemented in TypeScript but it should primarily be specified in lynx that then compiles to javascript.