Re: [Caml-list] Create a constraint between variant type and data list

2010-09-04 Thread Julien Signoles
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

Re: [Caml-list] Create a constraint between variant type and data list

2010-09-04 Thread Julien Signoles
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

Re: [Caml-list] Create a constraint between variant type and data list

2010-09-04 Thread Anil Madhavapeddy
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 --

[Caml-list] Create a constraint between variant type and data list

2010-09-03 Thread Sylvain Le Gall
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

Re: [Caml-list] Create a constraint between variant type and data list

2010-09-03 Thread Martin Jambon
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

Re: [Caml-list] Create a constraint between variant type and data list

2010-09-03 Thread Ashish Agarwal
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

Re: [Caml-list] Create a constraint between variant type and data list

2010-09-03 Thread Maxence Guesdon
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 = [