Browse thread
Create a constraint between variant type and data list
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Sylvain Le Gall <sylvain@l...> |
| Subject: | Re: Create a constraint between variant type and data list |
Hello all, On 03-09-2010, Sylvain Le Gall <sylvain@le-gall.net> wrote: > Hello all, > > I would like to somehow enforce that a variant type is associated with > an entry in a data list. > > For example, > > I would like to define: > > type license = GPL | LGPL > > and > > let data = [ GPL, "GNU Public license"; > LGPL, "GNU Lesser General Public license" ] > > Thank you for all your answer. I pick the one from oleg@okmij.org, I hide the license with a type and the creation of license is done in the module. The to_string/from_string is done by registering extra data in an Hashtable. See the implementation here. http://darcs.ocamlcore.org/cgi-bin/darcsweb.cgi?r=oasis;a=headblob;f=/src/oasis/OASISLicense.mli http://darcs.ocamlcore.org/cgi-bin/darcsweb.cgi?r=oasis;a=headblob;f=/src/oasis/OASISLicense.ml Regards, Sylvain Le Gall