Re: unification of array types
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
-[ Mon, Aug 01, 2016 at 04:47:22PM -0400, Sebastien Mondet ]----
> Your problem is with records not arrays :)
Scary. I blame too much scripting languages lately.
> Tuples work because they are "structurally" typed. The records do not work
> in your case because the field name `foo` is actually 2 completely
> different field names `S1.foo` and `S2.foo` (I don't know your setup but
> your code gives a bunch of warnings for me because of writing `{ foo = 1 }`
> without the module name).
OK, but I was expecting them to be the same given the shared signature.
But actually this simpler example also surprises me:
# module type S = sig type a = { foo : int } end;;
module type S = sig type a = { foo : int; } end
# module M1 : S = struct type a = { foo : int; } end;;
module M1 : S
# module M2 : S = struct type a = { foo : int; } end;;
module M2 : S
M1.a being another type than M2.a, despite they share a signature, is
counter-intuitive to me. I'm used to interpret "M1 and M2 have the same
signature S" as "The types of M1 and M2 are the same" ; but what it actually
means seems to be more "M1 and M2 define new types that look the same", which
is not very useful for records.