you would actually get the same behavior in ocaml, go to ocaml playground and copy paste this:
module MyModule = struct
let state = ref([])
let make (foo: string) =
state := foo :: !state;
state
end
let a1 = MyModule.make "a";;
let a2 = MyModule.make "b";;
Printf.printf "a1 = a2 ? %b" (!a1 = !a2);;
(* prints a1 = a2 ? true *)