Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] illegal permutation of structure fields?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus@m...>
Subject: [Caml-list] illegal permutation of structure fields?
Hello,

I've just found out to my surprise that the following does not work:

file: bla.ml
---------------------------------------------------------------------------
module type FOO = sig
  val x : int
  val y : int
end
---------------------------------------------------------------------------

file: bla.mli
---------------------------------------------------------------------------
module type FOO = sig
  val y : int
  val x : int
end
---------------------------------------------------------------------------

This yields the following error:

  The implementation bla.ml does not match the interface bla.cmi:
  Module type declarations do not match:
    module type FOO = sig val x : int val y : int end
  is not included in
    module type FOO = sig val y : int val x : int end
  Illegal permutation of structure fields

Why is this illegal? Wouldn't it be very straightforward to normalize
the signatures (e.g. sort elements by name) before matching them?

I knew that there is a somewhat similar restriction for record types,
which does not allow permutation of record elements in the type
definitions of implementation and interface.

In the latter case I see that without normalization there would be
problems correctly accessing record elements, but I don't quite understand
the rationale behind the first restriction.

Wouldn't normalization get rid of the problems in both cases? Or am I
overlooking anything?

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr