(* Interpreter using combinators factored as instructions : eval8 *) (* Value : プログラムの実行結果を表す型 *) type v = VNum of int | VFun of (s -> c -> t -> v) | VCont of c * s * t | VEnv of v list | VK of c and c = s -> t -> v and s = SNil | SCons of v * s | SAppend of s * s and t = TNil | Trail of c * s type i = s -> c -> t -> v (* プログラムの実行結果を文字列にする関数 *) (* Value.to_string : Value.t -> string *) let rec to_string value = match value with VNum (n) -> string_of_int n | VFun (_) -> "" | VCont (_, _, _) -> "" | VEnv (_) -> "" | VK (_) -> "" (* プログラムの実行結果をプリントする関数 *) (* Value.print : Value.t -> unit *) let print exp = let str = to_string exp in print_string str