Version française
Home     About     Download     Resources     Contact us    

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

Browse thread
Create a constraint between variant type and data list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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 <> 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, 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.;a=headblob;f=/src/oasis/OASISLicense.mli;a=headblob;f=/src/oasis/

Sylvain Le Gall