caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Michaël Grünewald" <michaelgrunewald@yahoo.fr>
To: caml-list@inria.fr
Subject: Defining a family of functors
Date: Mon, 26 Jan 2009 16:08:37 +0100	[thread overview]
Message-ID: <497DD1F5.7050702@yahoo.fr> (raw)

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


             reply	other threads:[~2009-01-26 15:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-26 15:08 Michaël Grünewald [this message]
2009-01-26 15:15 ` [Caml-list] " Jacques Carette
2009-01-27 14:30   ` Andrej Bauer
2009-01-27 14:47     ` Jacques Carette
2009-01-27 21:12       ` David Teller
2009-01-28  0:32         ` Nicolas Pouillard
2009-01-28 11:25           ` David Teller
2009-01-29  9:37             ` nicolas.pouillard
2009-01-29 10:40               ` David Allsopp
2009-01-29 21:14                 ` Mauricio Fernandez
2009-01-30  8:25                   ` Michaël Grünewald

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=497DD1F5.7050702@yahoo.fr \
    --to=michaelgrunewald@yahoo.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).