How do I check the type of a variable within a pattern matching in OCaml, version I currently use is 4.13, that is available online.
I found this post: OCaml: Type Checking ObjectsBut it doesnt really seem to solve the problem.
The sample code I tried is, here I want to get the type of x
and depending of what type is it return something different
let typecheck x = match #show x with |"val x : int" -> "int" |"val x : string" -> "string" | _ -> "Undefined";;
But I get Error: Syntax error
Maybe I can re-input the output of the directive somehow in the program?