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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id C812DBB83 for ; Fri, 18 Aug 2006 16:44:13 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7IEiD26017490 for ; Fri, 18 Aug 2006 16:44:13 +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 QAA14489 for ; Fri, 18 Aug 2006 16:44:12 +0200 (MET DST) Received: from coriana6.cis.mcmaster.ca (coriana6.CIS.McMaster.CA [130.113.128.17]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7IDZufC008365 for ; Fri, 18 Aug 2006 15:35:56 +0200 Received: from Dura7.UTS.McMaster.CA (dura7.UTS.McMaster.CA [130.113.196.62]) by coriana6.cis.mcmaster.ca (8.13.7/8.13.7) with ESMTP id k7IDZiHC003945 for ; Fri, 18 Aug 2006 09:35:51 -0400 (EDT) Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by Dura7.UTS.McMaster.CA (8.13.7/8.13.7) with ESMTP id k7IDZVHs029748 for ; Fri, 18 Aug 2006 09:35:31 -0400 Received: from [69.193.76.85] (account carette@univmail.cis.mcmaster.ca HELO [192.168.1.101]) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 136078805 for caml-list@inria.fr; Fri, 18 Aug 2006 09:35:31 -0400 Message-ID: <44E5C226.3030802@mcmaster.ca> Date: Fri, 18 Aug 2006 09:35:34 -0400 From: Jacques Carette Organization: McMaster University User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: caml-list@inria.fr Subject: How do I abstract out polymorphic variants via functors? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version-Mac: 4.7.1.128075, Antispam-Engine: 2.4.0.264935, Antispam-Data: 2006.8.18.52943 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' X-Spam: no; 0.00; variants:01 functors:01 sig:01 sig:01 abstraction:01 polymorphic:01 polymorphic:01 abstract:01 abstract:01 constraint:01 constraint:01 int:01 variant:02 mcmaster:02 types:03 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=none autolearn=disabled version=3.0.3 I have 3 module types, each of which start out "the same", viz: module type DETERMINANT = sig type 'a lstate type 'a tag_lstate = [`TDet of 'a lstate ] type ('b,'v) lm = ('a,'v,'s,'w) cmonad constraint 's = [> 'a tag_lstate] constraint 'b = 'a * 's * 'w ... end module type RANK = sig type 'a lstate = ('a, int ref) code type 'a tag_lstate = [`TRan of 'a lstate ] type ('b,'v) lm = ('a,'v,'s,'w) cmonad constraint 's = [> 'a tag_lstate] constraint 'b = 'a * 's * 'w ... end module type TRACKPIVOT = sig type 'a lstate type 'a tag_lstate = [`TPivot of 'a lstate ] type ('b,'v) lm = ('a,'v,'s,'w) cmonad constraint 's = [> 'a tag_lstate] constraint 'b = 'a * 's * 'w ... end [I realize that I will have to lose the RANK type's definition of 'a lstate when I abstract this out] The only thing different between those 3 is the name of the polymorphic variant - so clearly an opportunity for abstraction! But I can't seem to achieve this. Is there a way? Jacques