<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/01/3ac0c3210d8125d897f761fbf92e4bd8"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2009-01-26T15:16:34"
  subject="Re: [Caml-list] Defining a family of functors"
  prev="2009/01/058fceaf7ab816b8e53ee025d7e00cb1"
  next="2009/01/e09599b965f7f3400e85b669e98f0ce5"
  prev-in-thread="2009/01/f7ca13d9cc4ee13a6a08d9db855b9cb7"
  next-in-thread="2009/01/d2c63b2f7626796ec90499b50f2cf5a5"
  prev-thread="2009/01/075c78daae5e116a1bb9600fe4622e71"
  next-thread="2009/01/058fceaf7ab816b8e53ee025d7e00cb1"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Defining a family of functors">
<msg 
  url="2009/01/f7ca13d9cc4ee13a6a08d9db855b9cb7"
  from="Michaël_Grünewald &lt;michaelgrunewald@y...&gt;"
  author="Michaël_Grünewald"
  date="2009-01-26T15:08:38"
  subject="Defining a family of functors">
<msg 
  url="2009/01/3ac0c3210d8125d897f761fbf92e4bd8"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2009-01-26T15:16:34"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/d2c63b2f7626796ec90499b50f2cf5a5"
  from="Andrej Bauer &lt;andrej.bauer@a...&gt;"
  author="Andrej Bauer"
  date="2009-01-27T14:30:29"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/e0c885a82a80905f27ea953e549edbf7"
  from="Jacques Carette &lt;carette@m...&gt;"
  author="Jacques Carette"
  date="2009-01-27T14:48:20"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/8d8e54f793872ffd56af17cf4847374b"
  from="David Teller &lt;David.Teller@m...&gt;"
  author="David Teller"
  date="2009-01-27T21:12:52"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/1753e428b7e5e27bce761f4376dcfc36"
  from="Nicolas Pouillard &lt;nicolas.pouillard@g...&gt;"
  author="Nicolas Pouillard"
  date="2009-01-28T00:33:36"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/521ae12c093f87e36498da99ae549e1b"
  from="David Teller &lt;David.Teller@m...&gt;"
  author="David Teller"
  date="2009-01-28T21:18:29"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/ce1c7eaeee72626fbebda727986324b6"
  from=""
  author=""
  date="2009-01-29T09:38:48"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/d1e905442fb5ce55cfc4baef864b75cc"
  from="David Allsopp &lt;dra-news@m...&gt;"
  author="David Allsopp"
  date="2009-01-29T10:41:14"
  subject="RE: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/084cca644aebe0a7eee115861cf4acae"
  from="Mauricio Fernandez &lt;mfp@a...&gt;"
  author="Mauricio Fernandez"
  date="2009-01-29T21:15:00"
  subject="Re: [Caml-list] Defining a family of functors">
<msg 
  url="2009/01/05f780a2c38623a81af65fd384bb7637"
  from="Michaël_Grünewald &lt;michaelgrunewald@y...&gt;"
  author="Michaël_Grünewald"
  date="2009-01-30T08:25:30"
  subject="Re: [Caml-list] Defining a family of functors">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Without the projections, you can do it via a higher-order Functor which 
does a fold, ie lifting to the Functor level what one usually does to 
get an n-ary product out of a binary product.

With the projections, as this involves name-generation, I don't see how 
to do it without using camlp4.  Even my favourite sledgehammer, 
metocaml, can't help here.

Jacques

Michaël Grünewald wrote:
&gt; I am facing a situation that could be solved by ``defining a family of 
&gt; functors'', I describe the problem and would be very glad to get your 
&gt; views about it.
&gt;
&gt; To illustrate the situation, I will suppose A1, ..., An are modules 
&gt; implementing the same signature S, let's say S contains the usual 
&gt; opertations on groups (mathematical groups, you can replace this by 
&gt; vector spaces, or whatever). It is easy to write a Product2 functor
&gt;
&gt; Product2: A1:S -&gt; A2:S -&gt; S2
&gt;
&gt; producing an implementation for the direct product (with signature S) 
&gt; of the groups A1 and A2, plus injections j1 : A1.t -&gt; S2.t and j2: 
&gt; A2.t -&gt; S2.t and corresponding projections (the type t denotes the 
&gt; module thingie, as usual). This extension of S is here written S2.
&gt;
&gt; My problem is ``how do I remove the 2'' ? Would it be possible to 
&gt; define a functor scheme [:)]
&gt;
&gt; Productn: A1:S -&gt; .. -&gt; An:S -&gt; Sn
&gt;
&gt; able to instantiate concrete functors for any value of n ?
&gt;
&gt; It is possible to generate automatically appropriate code for small 
&gt; values of n, but I am looking for a better approach. It is simple to 
&gt; get close of the solution in the object paradigm, since I can simply 
&gt; put objects in an array and iterate over this array (IIRC this is the 
&gt; aggregate design pattern), but I do not see an easy way to define 
&gt; injections and projections.

</contents>

</message>

