Re: The constructor XX is defined in both types
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <CAPFanBHeqMHJEjHHuXXNDwVu0jYNiKND_K55k8M+xVuivNMfPA@mail.gmail.com> |
There is no risk. This is warning 30, which was meant to avoid user confusions before type-based disambiguation of fields and constructors was implemented. It should not be a default warning anymore (feel free to open an issue on the bugtracker for this), and you can safely disable it. In recent versions of OCaml (since 4.01.0), there are better warnings to control the readability risks of disambiguation of fields and constructor names: - warning 40 warns if disambiguation selects a name inside a module that is not opened in the current scope (I recommend using it) - warning 41 warns if a choice was made in absence of type information (defaulting to last-defined-name wins, not robust to addition of type annotations) (I recommend using it) - warning 42 warns if a type-directed disambiguation choice was different from what the last-defined-wins would have selected (this should be useful only when you want to make sure that your code will also compile with older OCaml versions that did not support typed-directed disambiguation) On Sat, Aug 1, 2015 at 9:55 AM, Sébastien Dailly [email protected] [ocaml_beginners] <[email protected]> wrote: > Hello, > > I'm tring to translate the xml schema in term of OCaml types : > >> type element = string Xml.Attributes.t >> and group = string Xml.Attributes.t * sub_group option >> and choice = string Xml.Attributes.t * sub_choice list >> and sequence = string Xml.Attributes.t * sub_choice list >> >> >> and sub_choice = >> | Element of element >> | Group of group >> | Choice of choice >> | Sequence of sequence >> >> and sub_group = >> | Choice of choice >> | Sequence of sequence >> > > The compilation give me the warning : > >> the constructor Choice is defined in both types sub_choice and sub_group > >> the constructor Sequence is defined in both types sub_choice and sub_group. > > I know I could use polymorphic variants to prevent this, but I want to > restrict each type with the contructors defined in the schema. (I also > want to be as close as possible with the xsd names types). > > My question is : what do I risks ? I did some tests and this seems to > work correctly in pattern matching and I did not see where it could > break the code. > > Thank you > > > ------------------------------------ > Posted by: =?UTF-8?B?U8OpYmFzdGllbiBEYWlsbHk=?= <[email protected]> > ------------------------------------ > > Archives up to December 31, 2011 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners > The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr > Attachments are banned and you're asked to be polite, avoid flames etc. > ------------------------------------ > > Yahoo Groups Links > > >