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
Type constraint to explain that a polymorphic variants is included into another
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-10-08 (22:10)
From: Sylvain Le Gall <sylvain@l...>
Subject: Re: Type constraint to explain that a polymorphic variants is included into another
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

Sylvain Le Gall