I am learning about OCaml's OOP constructs and partially implemented this today until I realized I have no idea how to represent a polymorphic match statement without using the type keyword outside of the object.
class bar (param:string) =
object (code)
end;;
class foo param =
object (code)
initializer
match param with
string -> Printf.printf "param is a string"
| bar -> Printf.printf "param is a bar"
end;;
let b = new bar "a string";;
let f1 = new foo "test";;
let f2 = new foo b;;
Is it possible to determine the type of object passed in on-the-fly?