Yesterday I encountered an ocaml error that, if I can now make some sense out of it -- it's not properly speaking a bug -- was quite confusing at first and took me some time to figure out.

What happens is that a sum-type defined in a module can implicitely be turned into abstract because of its inner contents.

Here is a small example:
------
module F (A : sig type a end) = struct
 type a = A.a
 type t = X of A.a
end

(* if A.a is abstract, the type F.t is made abstract *)
module A = F (struct type a end)
(*
 The inferred interface is:
 module A : sig type a type t end

I figure ocaml can't guess what to put in the interface for the definition of t, but maybe an error would be better than silently turning it into abstract ?
*)

(* it gets confusing in the following use case (and of course if type t
  has many cases and you just added an abstract type somewhere deep) *)
let _ = A.X (assert false)
 (* the constructor A.X is not found *)

(* if t is defined as "X of a" instead of "X of A.a", no problem arises *)
------

I don't know exactly what to do with it, but maybe it should be made an error ? (types escaping their scope usually are)

Louis

--
Louis Gesbert
R & D @ MLstate
15, rue Berlier
75013 Paris

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to