Hi all,

I have just met a strange problem (it might have already been
answered, but I can't find the it) while using camlp4 to generate a
polymorphic type like:

type t = [ `A of int * int | `B of string ]

error msg "The present constructor A has a conjunctive type" is thrown
by the compiler.

I followed the ocaml source code, found in ocaml-3.10.2/typing/typetexp.ml
Line 290, it does the following check in add_field function:
      if List.length stl > 1 || c && stl <> [] then
                  raise(Error(styp.ptyp_loc, Present_has_conjunction l));

Sorry, I can't fully understand the source code, but it seems we can
only define a polymorphic variant with only one additional type
declaration, like
               `A of int   or `A of (int * int)
 rather than `A of int * int

It looks wired, as we can directly define
type t = [ `A of int * int | `B of string ]  in toploop or a *.ml file.

Or I have some mis-understanding in this part.

Thanks for any help.

Best regards,
Conglun

_______________________________________________
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