It is possible, sort of, through the module Obj
. Analysis of objects using functions Obj
, if everything is done correctly, will not lead to the failure of your program; but you need to be careful if you want meaningful results.
let equal_constructors (x : 'a) (y : 'a) =
let r = Obj.repr x and s = Obj.repr y in
if Obj.is_int r && Obj.is_int s then (Obj.obj r : int) = (Obj.obj s : int) else
if Obj.is_block r && Obj.is_block s then Obj.tag r = Obj.tag s else
false
( ) true
, , false
. equal_constructors
; true
false
, .