You should define each term in OCaml program, and give them to Miki Beta.
Let me show how to define `value` term as an example.
`value` term consists of two alternatives: `var` and `abst`.
For each alternative, you should define the three features:
- constructor's name (string typed)
- representation of the type (Code typed)
- renderer function
We know that each three features for `var` and `abst` are as follows.
1. | constructor's name | : | "var" |
2. | representation of the type | : | PS |
3. | renderer function | : | x |
| (when the string parameter for PS is `x`) |
|
1. | constructor's name | : | "abst" |
2. | representation of the type | : | Times (PS, I expr_i) |
3. | renderer function | : | λx. y |
| (when the string parameter for PS is `x` and `I expr_i` is rendered as `y`) |
As OCaml program, you should define the three features as a tuple. Then collect them in a single list.
let value_def =
[("var",
PS,
fun t -> t 0);
("abst",
Times (PS, I expr_i),
fun t -> combineH [create_str "(λ"; t 0; create_str ". "; t 1; create_str ")"])
]
After defining the list of tuples for each term (say `value_def`, ... , `judgement_def`),
then store all of them in one list named `termDefs`.
They should be paired with string representation of meta variable
(how you want to draw meta variable for the termX).
Note that each of list indexes corresponds to a term's ordinal number.
You define a module, which contains the list `termDefs` and an int `top_i`.
`top_i` is the ordinal number for the outermost term.
Both `termDefs` and `top_i` must be declared with these names.
module Terms = struct
(* top_i : int *)
(* The ordinal number for the outermost term *)
let top_i = judgement_i
(* termDefs : string * termdef_t list *)
(* list of definitions of each terms' name, types, and how to draw them *)
let termDefs = [("v", value_def); ("e", exp_def); ("t", typ_def); ("env", env_def); ("judgement", judgement_def)]
end
Pass the defined module to a functor in Miki Beta `Fix.F`,
and you will finally get the wrapped module that is needed to create the GUI world.
Let us call the module `Fixs`.
module Fixs = Fix.F (Terms)