From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id C596DBB84 for ; Mon, 26 Jan 2009 16:08:38 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkYCAJ9gfUmYTQLKmWdsb2JhbACTfgEBAQEBCAsKBxGne41MhUs X-IronPort-AV: E=Sophos;i="4.37,325,1231110000"; d="scan'208";a="34285117" Received: from amazone2.ujf-grenoble.fr ([152.77.2.202]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Jan 2009 16:08:38 +0100 Received: from tana2.ujf-grenoble.fr (tana2.ujf-grenoble.fr [152.77.24.22]) by amazone2.ujf-grenoble.fr (8.13.7/8.13.7/Configured by JE 21 07 2006) with ESMTP id n0QF8c8J031531 for ; Mon, 26 Jan 2009 16:08:38 +0100 (CET) Received: from localhost (unknown [127.0.0.1]) by tana2.ujf-grenoble.fr (Postfix) with ESMTP id 599DA5646D for ; Mon, 26 Jan 2009 16:08:38 +0100 (CET) X-UJF-AV: Scanned on tana2.ujf-grenoble.fr Received: from tibre2.ujf-grenoble.fr (tibre2.ujf-grenoble.fr [152.77.24.10]) by tana2.ujf-grenoble.fr (Postfix) with ESMTP id 376F95646A for ; Mon, 26 Jan 2009 16:08:38 +0100 (CET) Received: from fourier.ujf-grenoble.fr (fourier.ujf-grenoble.fr [152.77.212.18]) by tibre2.ujf-grenoble.fr (8.14.2/8.14.2) with ESMTP id n0QF8avq054222 for ; Mon, 26 Jan 2009 16:08:38 +0100 (CET) (envelope-from michaelgrunewald@yahoo.fr) Received: from localhost (localhost [127.0.0.1]) by fourier.ujf-grenoble.fr (Postfix) with ESMTP id 36256D2D87 for ; Mon, 26 Jan 2009 16:08:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at fourier.ujf-grenoble.fr Received: from fourier.ujf-grenoble.fr ([127.0.0.1]) by localhost (fourier.ujf-grenoble.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GvPMzTP-B6gN for ; Mon, 26 Jan 2009 16:08:42 +0100 (CET) Received: from [193.48.255.208] (vanparys.ujf-grenoble.fr [193.48.255.208]) by fourier.ujf-grenoble.fr (Postfix) with ESMTP id 16E4FD2CAF for ; Mon, 26 Jan 2009 16:08:42 +0100 (CET) Message-ID: <497DD1F5.7050702@yahoo.fr> Date: Mon, 26 Jan 2009 16:08:37 +0100 From: =?ISO-8859-1?Q?Micha=EBl_Gr=FCnewald?= User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Defining a family of functors Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; functors:01 functor:01 denotes:01 functor:01 functors:01 iirc:01 ...,:98 define:02 define:02 modules:02 groups:02 groups:02 objects:02 defining:02 defining:02 I am facing a situation that could be solved by ``defining a family of functors'', I describe the problem and would be very glad to get your views about it. To illustrate the situation, I will suppose A1, ..., An are modules implementing the same signature S, let's say S contains the usual opertations on groups (mathematical groups, you can replace this by vector spaces, or whatever). It is easy to write a Product2 functor Product2: A1:S -> A2:S -> S2 producing an implementation for the direct product (with signature S) of the groups A1 and A2, plus injections j1 : A1.t -> S2.t and j2: A2.t -> S2.t and corresponding projections (the type t denotes the module thingie, as usual). This extension of S is here written S2. My problem is ``how do I remove the 2'' ? Would it be possible to define a functor scheme [:)] Productn: A1:S -> .. -> An:S -> Sn able to instantiate concrete functors for any value of n ? It is possible to generate automatically appropriate code for small values of n, but I am looking for a better approach. It is simple to get close of the solution in the object paradigm, since I can simply put objects in an array and iterate over this array (IIRC this is the aggregate design pattern), but I do not see an easy way to define injections and projections. -- Thanks for your suggestions, Michaël