I finished the monadic style lambda emitter. Pretty sure it is correct now, at least in theory. A number of invariants just dropped into the basket, it looks correct. Leaves getting rid of some bugs.
I now have a small new problem, the Hi language assumes integers to be of system pointer width, which is 64 bits, and uses that to translate strings to their integer representation. The ocaml interpreter uses 31 tagged bit representation, it cannot produce the integer representation directly, so I will do some name mangling of identifiers to 3 chars to get to a bootstrap.
I wanted to serialize heaps. But there are two problems. One is that heap serializer probably just wastes too much memory, and I want to change the representation of it. Two is that, in the end, serialization of Hi structures to memory from the compiler directly will probably just give better portability, and possibly performance anyway, drops reliance on the heap serializer, and can be reused easier for parallel processing. So, I am gonna write a serialization interface, and build serialization code for the AST.