From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q47GlnMH015641 for ; Mon, 7 May 2012 18:47:49 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsMBAPL7p0/ZSMDdkWdsb2JhbABEsxwiAQEBAQkLCwcUAySCDAEBBAEnEz8FCwshJQ8BBCghE4d/AQMGCbB7HysFiVuRHwSbYY1K X-IronPort-AV: E=Sophos;i="4.75,544,1330902000"; d="scan'208";a="157083025" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 May 2012 18:47:44 +0200 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate01.web.de (Postfix) with ESMTP id 4821C1ADF7052 for ; Mon, 7 May 2012 18:47:44 +0200 (CEST) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0MQvxm-1Safhp3DHq-00ULnH; Mon, 07 May 2012 18:47:44 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1SRR66-00063c-IR; Mon, 07 May 2012 18:47:42 +0200 From: Goswin von Brederlow To: Dan Bensen Cc: caml-list@inria.fr References: <1336383633.2612.YahooMailRC@web180006.mail.gq1.yahoo.com> Date: Mon, 07 May 2012 18:47:42 +0200 In-Reply-To: <1336383633.2612.YahooMailRC@web180006.mail.gq1.yahoo.com> (Dan Bensen's message of "Mon, 7 May 2012 02:40:33 -0700 (PDT)") Message-ID: <877gwokkep.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Provags-ID: V02:K0:Wra7AcwgE6Jq+M1S5noUlGTtB50E5pPw/Ab9KX2teS7 Yx7CxvOeTR6lrsnBp5AsMx9g/VSKVxyFj/8iiZJRgs/Aga1C2Z Y4iENThd4z9c1v0DH5ZkKKv66L3ew4IC76z+HBkhdNWQxhesfB rg5G7gB7NFzrjuArzlADQzdrNZfn69zwbrFVCH65ThtQ+Ic6q+ x2RC11DsoOC5GSAqnDQUw== Subject: Re: [Caml-list] extending user-defined polymorphic variant types Dan Bensen writes: > I'm trying to write a functor that extends a user-supplied polymorphic > variant type (PVT). How do you declare the user's type in the signature > for the argument to the functor without locking in the individual variant > definitions? > The code below (in revised syntax) generates an error message that says > the type isn't a PVT. > > code: > >> module type Reader = sig type ast; end; >> >> module Make (Read: Reader) = struct >> type ast = [= Read.ast | `Lid of string]; >> end; > > message: > >> Error: The type Read.ast is not a polymorphic variant type > > How do you make ast a PVT while allowing the user to > specify the variants? Even if that did work how usefull would that be? You couldn't write let foo = function | `Lid s -> () | x -> Read.foo x unless Read.foo allows [> Read.ast]. In which case you don't need a functor but can just implement foo straight up. What is your use case? What do you want to do? MfG Goswin