This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

generic data type -> int function
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2005-03-31 (14:34) From: Hal Daume III Subject: Re: [Caml-list] generic data type -> int function
```> > type etype = GPE | LOC | ORG | PER | NAE_e | BOS_e
> > type mtype = BAR | NAM | NOM | PRE | PRO | OTHER | NAE_m | BOS_m
> > type pairs = EM of etype*mtype | EE of etype*etype | MM of mtype*mtype
> > type pairs2 = EP of etype * pairs | MP of mtype * pairs
> >
> >
> > Corresponding output:
> >
> > let int_of_etype = function | GPE -> 0 | LOC -> 1 | ORG -> 2 | PER -> 3 | NAE_e -> 4 | BOS_e -> 5
> > let int_of_mtype = function | BAR -> 0 | NAM -> 1 | NOM -> 2 | PRE -> 3 | PRO -> 4 | OTHER -> 5 | NAE_m -> 6 | BOS_m -> 7
>
>
> ...ooops...  GPE as well as BAR has the same output-value...
> ...so... if there is no problem with that kind of similar integers,
> why don't you use Kims solution?!
> Ut seemed to me that it has solved your problem, at least in this respect.

Because it cannot handle the 'type pairs' or 'type pairs2' above.  The
enumerations are unique per type.

--
Hal Daume III                                   | hdaume@isi.edu
"Arrest this man, he talks in maths."           | www.isi.edu/~hdaume

```