From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B4510BC57 for ; Fri, 3 Sep 2010 23:30:06 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgEFAPIFgUxQW+UMgWdsb2JhbACTa40mFQEBFiIiwA+FOwSIcYEo X-IronPort-AV: E=Sophos;i="4.56,315,1280700000"; d="scan'208";a="68840752" Received: from lo.gmane.org ([80.91.229.12]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Sep 2010 23:30:06 +0200 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ordpk-0001a4-ES for caml-list@inria.fr; Fri, 03 Sep 2010 23:30:04 +0200 Received: from ks368928.kimsufi.com ([94.23.39.26]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Sep 2010 23:30:04 +0200 Received: from sylvain by ks368928.kimsufi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Sep 2010 23:30:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: Create a constraint between variant type and data list Date: Fri, 3 Sep 2010 21:28:24 +0000 (UTC) Message-ID: References: X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ks368928.kimsufi.com User-Agent: slrn/pre1.0.0-11 (Linux) X-Spam: no; 0.00; le-gall:01 constructors:01 datatype:01 camlp:01 markus:01 mottl's:01 ocaml:01 ocaml:01 camlp:01 wrote:01 constraint:01 variant:02 data:02 declaration:02 generated:05 On 03-09-2010, bluestorm wrote: > Hi, > > Finally, I have a third solution based on code generation : given my > first solution (turning the association list into a function), what > you need is only a list of all the constructors (and you can build > your assoc list with List.map (fun x -> x, assoc_function x)). This > can easily be generated from the datatype declaration using direct > camlp4, or Markus Mottl's type-conv ( > http://www.ocaml.info/home/ocaml_sources.html#toc11 ). > Your answer and the one from Martin/Ashish, makes me think that I need to go back to camlp4/type-conv... I would have like to avoid this solution, but I think it is the best one. Thanks for all your answer... Regards, Sylvain Le Gall p.s.: this remains an open problem, so solutions are still welcome ;-)