Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Jake Donham <jake@d...>
Subject: Re: [Caml-list] Type constraint to explain that a polymorphic variants is included into another
On Fri, Oct 8, 2010 at 10:13 AM, Sylvain Le Gall <sylvain@le-gall.net> 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.

Jake