I have a bit of a brainteaser and was hoping someone has a bit of time to be my rubberduck.
So I am working on a DSL and want to build a Runtime for that language to be executed in.
A program in that DSL is effectively a function from Runtime => Runtime
(modulo error/io monad).
The Runtime contains all the bindings that the programs can read and are writing.
Each program defines the bindings it requires as well as the ones it adds.
Besides that I have a couple combinators AndThen
for sequential programs where the rhs has access to what lhs writes.
Choice
for a finite, exhaustive if-like things. And all
for combining n programs that are run against the same runtime instance and whose results are aggregates.
so e.g my current compiler for AndThen
just does function composition. It's fairly straight forwards.