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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3D528BB83 for ; Tue, 18 Jul 2006 06:31:47 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6I4VkHa026401 for ; Tue, 18 Jul 2006 06:31:46 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id GAA15646 for ; Tue, 18 Jul 2006 06:31:46 +0200 (MET DST) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.183]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6I4VjrN001934 for ; Tue, 18 Jul 2006 06:31:45 +0200 Received: by py-out-1112.google.com with SMTP id f25so123671pyf for ; Mon, 17 Jul 2006 21:31:45 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=OoJOu5D+26XVvTS7j1mifKIktbLzRTHR61EKP2rhtSLyLdAruwrXI8kKVqPt/9pOVL80z0/PDQEnJ3rNsrvdSXvk+l9xUaMRlzCpGbBzES4dqwi3MaH7hL6k3GJ/sx7YbytYNXQEbUsOCtABnQY97ycIOEqpcgpWdXQsT/59HT0= Received: by 10.35.61.14 with SMTP id o14mr5013768pyk; Mon, 17 Jul 2006 21:31:45 -0700 (PDT) Received: by 10.35.132.20 with HTTP; Mon, 17 Jul 2006 21:31:45 -0700 (PDT) Message-ID: <875c7e070607172131m47260672h85e2ed12b054581c@mail.gmail.com> Date: Tue, 18 Jul 2006 00:31:45 -0400 From: "Chris King" To: "O'Caml Mailing List" Subject: Module type troubles MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 44BC6431.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 44BC6432.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44BC6431.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; constructors:01 foo:01 foo:01 constructors:01 foobar:01 foobar:01 struct:01 struct:01 sig:01 val:01 compiler:01 polymorphic:01 complains:01 define:01 modules:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 (Sorry for the long explaination that follows, it's the most concise example I can come up with.) Say I have two polymorphic types with associated constructors: type 'a foo = { foo: 'a } let make_foo a = { foo = a } type 'a bar = { bar: 'a } let make_bar a = { bar = a } Using the "combine" function, I am able to define constructors for compound types: let combine make_a make_b (a, b) = make_a a, make_b b type 'c foobar = 'a foo * 'b bar constraint 'c = 'a * 'b let make_foobar c: 'c foobar = combine make_foo make_bar c type 'c foobarfoo = 'a foobar * 'b foo constraint 'c = 'a * 'b let make_foobarfoo c: 'c foobarfoo = combine make_foobar make_foo c Now I would like to do the same thing with modules: module Foo = struct type 'a t = { foo: 'a } let make a = { foo = a } end module Bar = struct type 'a t = { bar: 'a } let make a = { bar = a } end module type Combinable = sig type 'a t val make: 'a -> 'a t end module Combine(A: Combinable)(B: Combinable) = struct type 'c t = 'a A.t * 'b B.t constraint 'c = 'a * 'b let make (a, b) = A.make a, B.make b end module FooBar = Combine(Foo)(Bar) module FooBarFoo = Combine(FooBar)(Foo) Everything works fine until the last line. The compiler complains: Type declarations do not match: type 'a t = 'b Foo.t * 'c Bar.t constraint 'a = 'b * 'c is not included in type 'a t I realize that this is because type 'a FooBar.t cannot exist without its constraint. Is there a way to acheive the module structure I want, save using Obj? Thanks in advance, Chris King