From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 4A17CBBFA for ; Wed, 22 Jun 2005 06:53:54 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j5M4rrIL022633 for ; Wed, 22 Jun 2005 06:53:54 +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 GAA09244 for ; Wed, 22 Jun 2005 06:53:53 +0200 (MET DST) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j5M4rqoK022629 for ; Wed, 22 Jun 2005 06:53:53 +0200 Received: by wproxy.gmail.com with SMTP id 69so105492wri for ; Tue, 21 Jun 2005 21:53:52 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=oqJg7MVRboc+lMTayY7OuM3jTsS6pZETENGQk/Tvpf20KICXtjrJubIS1PufmaEyKNvodpvfNpPl2dEAj5L9gXLYhYcSR7nWn26gaNbbV5EsPb9ag3haZmGYfCKuTh+PQdj8TAyy5fO45z6gQKjRj59jVFrMPmqazTWqtaMapbs= Received: by 10.54.57.45 with SMTP id f45mr203042wra; Tue, 21 Jun 2005 21:53:52 -0700 (PDT) Received: by 10.54.42.71 with HTTP; Tue, 21 Jun 2005 21:53:52 -0700 (PDT) Message-ID: <8ecdad970506212153417f77b5@mail.gmail.com> Date: Wed, 22 Jun 2005 00:53:52 -0400 From: Scott Duckworth Reply-To: Scott Duckworth To: caml-list Subject: type troubles with functors Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at nez-perce with ID 42B8EEE1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42B8EEE0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; functors:01 functor:01 mli:01 ord:01 elt:01 ord:01 sig:01 val:01 sig:01 elt:01 val:01 struct:01 functor:01 ocaml's:01 ...:98 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.2 X-Spam-Level: I'm having trouble figuring out a way to represent functor modules as types in a module type definition. For lack of a better way of explaining it, here's the problem I'm having in code: ************************************* (* OrderedSet.mli *) (* Ordered sets over ordered types *) module type OrderedType =3D (* same as in .ml file *) module type S =3D (* same as in .ml file *) module Make (Ord : OrderedType) : S with type elt =3D Ord.t ************************************* (* OrderedSet.ml *) (* Ordered sets over ordered types *) module type OrderedType =3D sig =09type t =09val compare : t -> t -> int end module type S =3D sig =09type elt =09type t =09val to_list : t -> elt list =09val to_set : t -> EltSet.t (* PROBLEM *) =09(* ... *) end module Make (Ord : OrderedType) =3D struct =09module EltSet =3D Set.Make(Ord) (* THIS IS WHAT I WANT TO RETURN *) =09type elt =3D Ord.t =09type t =3D { l : elt list; s : EltSet.t } =09let to_list s =3D s.l =09let to_set s =3D s.s (* THIS IS WHERE I WANT TO RETURN A SET *) =09(* ... *) end ************************************* I realize that EltSet.t is not defined at the two points I have noted a problem, I'm simply stating my intention. The problem is that OrderdSet.S does not know the OrderedSet.OrderedType that will be used in OrderedSet.Make, but it does know that it will be of type Set.S.t.=20 (This is one instance where I wish Set was implemented as a parameterized type, not a functor.) My question is, how can I correctly type to_set? I have tried many different configurations of Set.Make and Set.S, but none of them have worked. If anyone knows how this can be done in OCaml's type system, please let me know. Thanks! --=20 Scott Duckworth