You can also avoid this logic issue by using modules, which is what we typically do:
module Dog = struct
type t = { name : string }
end
module Cat = struct
type t = { name : string }
end
Now we will have to create and pattern-match the record types using their explicit module names eg { Dog.name = "Brian" }
.