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 C902ABC57 for ; Sat, 9 Oct 2010 00:10:21 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AigFAFszr0xQW+UMgWdsb2JhbACUSI16FQEBFiIiv1yFRwSKQA X-IronPort-AV: E=Sophos;i="4.57,305,1283724000"; d="scan'208";a="73051189" Received: from lo.gmane.org ([80.91.229.12]) by mail4-smtp-sop.national.inria.fr with ESMTP; 09 Oct 2010 00:10:21 +0200 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P4L8r-0007lT-Pn for caml-list@inria.fr; Sat, 09 Oct 2010 00:10:17 +0200 Received: from avelizy-155-1-1-48.w83-199.abo.wanadoo.fr ([83.199.40.48]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 09 Oct 2010 00:10:17 +0200 Received: from sylvain by avelizy-155-1-1-48.w83-199.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 09 Oct 2010 00:10:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: Type constraint to explain that a polymorphic variants is included into another Date: Fri, 8 Oct 2010 22:10:09 +0000 (UTC) Message-ID: References: X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: avelizy-155-1-1-48.w83-199.abo.wanadoo.fr User-Agent: slrn/pre1.0.0-18 (Linux) X-Spam: no; 0.00; le-gall:01 variants:01 le-gall:01 subtype:01 subtyping:01 functor:01 compiler:01 polymorphic:01 wrote:01 wrote:01 abstract:01 compile:01 constraint:01 explicitly:02 seems:03 On 08-10-2010, Jake Donham wrote: > On Fri, Oct 8, 2010 at 10:13 AM, Sylvain Le Gall wrote: >> This code doesn't compile because I see no way to explain that F.kind is >> included into plugin_kind. > > As you have written it, F.kind is of course completely abstract. I am > not sure where you need F.kind to be a strict subtype of plugin_kind, > but you could say type kind = plugin_kind (this seems a bit useless > however). > > I don't think there is a way to use subtyping implicitly when applying > a functor, but you can always do it explicitly by interposing a module > of signature PLUGIN_FAMILY which embeds the specific kind in > plugin_kind and passes the other components through. > > You could also have a general and a specific type in the plugin > signature, and use the general one for general operations (e.g. help) > but the specific one wherever that is needed. I am not sure I > understand what you're trying to achieve however. > My goal is that the compiler prevents me to do Build.act pkg.plugin_install -> because plugin_install is of type [`Install] plugin and Build.act needs [`Build] plugin but allow me to do help pkg.plugin_install -> because help needs [`Build | `Install] plugin. But maybe I am missing something here and try to overengineer something simple. Regards, Sylvain Le Gall