I'm trying to write a module that convert something like x:int = if true then 3 else 5 to a string
Here's the code I have so far
module Ast =structtype typ = Bool | Inttype var = A | B | C | D | E | Ftype exp = Const of int * typ | App of string * exp list | If of exp * exp * exp | And of exp * exp | Or of exp * exp | Id of var * typ * explet rec toString (t) = let formatDec1(va,ty,e) = ??? match t with Const(n, _) -> print_int n | App(id, [e1; e2]) -> formatter("" ^ id ^ "", e1, e2) | App(id, [e1]) -> formatter("" ^ id ^ "", e1, Const(0, Int)) | App(id, _) -> formatter("" ^ id ^ "", Const(0, Int), Const(0, Int)) | If(e1, e2, e3) -> formatIf(e1, e2, e3) | And(e1, e2) -> formatter("&& ", e1, e2) | Or(e1, e2) -> formatter(" || ", e1, e2) | Id(va,ty,e) -> formatDecl(va,ty,e)end
I'm still a beginner in OCaml and couldn't find anything about converting to a string online. Thanks!