Hello Sylvain,
2010/9/3 Sylvain Le Gall sylv...@le-gall.net
I would like to define:
type license = GPL | LGPL
and
let data = [ GPL, GNU Public license;
LGPL, GNU Lesser General Public license ]
I would like to enforce that all variants of license are in the
association
let () = match GPL with
| GPL | LGPL -
assert
(let s = Do not forget to add new constructors to the data list
above. in
Format.ifprintf Format.std_formatter %s s;
true)
Sorry could be much better like this:
let () = match GPL with GPL | LGPL -
ignore Do
Here's a (very) quick and dirty implementation that will automatically populate
data, using our dynamic typing library ( http://github.com/mirage/dyntype ).
You just need to fill in desc_of_license with the matching descriptions, and
data will be auto-populated at program startup.
-anil
--
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 ]
I would like to
Sylvain Le Gall 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
See the Enum section of deriving:
http://code.google.com/p/deriving/wiki/Introduction
I haven't used it myself so cannot comment on how well it works.
On Fri, Sep 3, 2010 at 2:51 PM, Martin Jambon martin.jam...@ens-lyon.orgwrote:
Sylvain Le Gall wrote:
Hello all,
I would like to somehow
Le Fri, 3 Sep 2010 17:16:48 + (UTC),
Sylvain Le Gall sylv...@le-gall.net a écrit :
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 = [