`Acutis_internals.Instruct`

Define the instructions to evaluate a `Compile`

result at runtime.

To evaluate a `Compile.t`

, we define an abstract language in "tagless final" style by using a module type. Each language construct is defined as an OCaml function so we automatically inherit the full type safety of any OCaml program.

We can evaluate the language in multiple ways. For example we can interpret it as an OCaml program, we can pretty-print it, or we can output it in a concrete language like JavaScript (which is just another form of pretty-printing). We can also add modular optimizations.

Our abstract language is roughly based on JavaScript. It has expressions, statements, loops, let-bindings, mutable references, hash tables, first-class functions, and asynchronous monads (i.e. promises).

`module type SEM = sig ... end`

Define the semantics of our abstract language.

Create evaluation instructions for a given language implementation.

`module type TRANS = sig ... end`

To transform the language's output, such as for an optimization, we need to define a module that can translate terms "forward" to the transformed state and "backward" to the original representation.

```
module MakeTrans
(T : TRANS)
(F : SEM with type 'a exp = 'a T.from_exp and type 'a stmt = 'a T.from_stmt) :
SEM
with type 'a stmt = 'a T.stmt
and type 'a obs = 'a F.obs
and type 'a exp = 'a T.exp
and type 'a ref = 'a F.ref
and type 'a hashtbl = 'a F.hashtbl
and type buffer = F.buffer
and type 'a promise = 'a F.promise
and type 'a External.linear = 'a F.External.linear
and type 'a External.assoc = 'a F.External.assoc
and type External.t = F.External.t
and type 'a External.classify = 'a F.External.classify
and type Data.t = F.Data.t
and type import = F.import
```

Apply a transformation module and a semantics module to produce a new semantics module that uses the transformation state.

```
val pp :
(Stdlib__Format.formatter -> 'a -> unit) ->
Stdlib__Format.formatter ->
'a0 Compile.t ->
unit
```

Pretty-print the instructions for a compiled template.